[google-appengine] Same entity with several parents?

2009-10-13 Thread andreas_b

Hi all.

I've only been working with relational databases up to now, and have
some problems with JDO.

I seem to have some trouble grasping the basic design patterns with
POJO/JDO here.
This is probably a very basic issue, but its hard when the mind is
setup to think from an entirely different perspective :-).

So, what I want to do here is to have child objects of the same type
referenced from different parents.
For example...

Say we have a class Person, class CarRegister, class Car.

A Car class with a Key.

class Car {

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;

...other persistent objects...

}

In Person, I have a list of Car objects that the person owns.

class Person {

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private List ownedCars;

}

In CarRegister, I also have a list of all Car objects registered.

class CarRegister{

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private List registeredCars;

}


Is this possible? The documentation seem to suggest that a key is made
up of the entity parent id and some other stuff, which should mean
that the above wouldn't work. (The key value includes the key of the
entity group parent (if any) and either the app-assigned string ID or
the system-generated numeric ID).

I could of course save a list of keys/ids to Car objects instead, but
that to me would kind of defeat the purpose of this kind of database.
So I want a List of Car objects in both Person and CarRegister, and
they must somehow share the same objects in the database. This must be
one of the basic use cases, but I have been unable to find an optimal
solution for it.

Thanks in advance.

BR, Andreas



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Same entity with several parents?

2009-10-14 Thread andreas_b

Hi.

Well, the restraint seems to be on the way GAE handles keys. There are
4 types of keys that can be used, but the only ones that are assigned
an ID by the system is Long, Key and encodedKey.
I want the system to automatically assign an id to new objects that
are created, so that limits me to those choices.
I can't use the Long variant on child objects, so I'm stuck with the
Key/encoded Key string variants, and according to
http://code.google.com/appengine/docs/java/datastore/creatinggettinganddeletingdata.html#Keys
the system generated key is made up of the entity parent id, among
other things.

I use JDO directly, not the low level API. But the key-handling is
still dependent on GAE datastore I suppose...

/ Andreas

On Oct 14, 8:10 am, Roy Smith  wrote:
> It sounds like you're reading documentation for the Low Level API.
> I don't use JDO, but I suspect that JDO does not have that single-parent
> constraint.
>
> On Tue, Oct 13, 2009 at 8:49 PM, andreas_b wrote:
>
>
>
> > Hi all.
>
> > I've only been working with relational databases up to now, and have
> > some problems with JDO.
>
> > I seem to have some trouble grasping the basic design patterns with
> > POJO/JDO here.
> > This is probably a very basic issue, but its hard when the mind is
> > setup to think from an entirely different perspective :-).
>
> > So, what I want to do here is to have child objects of the same type
> > referenced from different parents.
> > For example...
>
> > Say we have a class Person, class CarRegister, class Car.
>
> > A Car class with a Key.
>
> > class Car {
>
> >   �...@primarykey
> >   �...@persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> >    private Key key;
>
> >    ...other persistent objects...
>
> > }
>
> > In Person, I have a list of Car objects that the person owns.
>
> > class Person {
>
> >   �...@primarykey
> >   �...@persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> >    private Long id;
> >   �...@persistent
> >    private List ownedCars;
>
> > }
>
> > In CarRegister, I also have a list of all Car objects registered.
>
> > class CarRegister{
>
> >   �...@primarykey
> >   �...@persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> >    private Long id;
> >   �...@persistent
> >    private List registeredCars;
>
> > }
>
> > Is this possible? The documentation seem to suggest that a key is made
> > up of the entity parent id and some other stuff, which should mean
> > that the above wouldn't work. (The key value includes the key of the
> > entity group parent (if any) and either the app-assigned string ID or
> > the system-generated numeric ID).
>
> > I could of course save a list of keys/ids to Car objects instead, but
> > that to me would kind of defeat the purpose of this kind of database.
> > So I want a List of Car objects in both Person and CarRegister, and
> > they must somehow share the same objects in the database. This must be
> > one of the basic use cases, but I have been unable to find an optimal
> > solution for it.
>
> > Thanks in advance.
>
> > BR, Andreas
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Multiple datastores or share datastore in one app

2009-12-01 Thread andreas_b
Hi all.

I'm working on a GWT/GAE project where the idea is to create a portal
for sport teams. Each sport team can sign up to get an account where
they can register players, keep track of leagues, matches, statistics
and so on. Each team should also be able to use their own domain,
which automatically should load the site with their configuration when
entered (basically just load the gwt-app with some url-parameter that
is forwarded to server-side).

So, coming from a normal SQL-environment, it seems to me that each
team that signs up should get their own private database for all their
data. As I understand it, this is not possible with GAE datastore?
There is a one-to-one mapping between an application and a datastore?

If this is the case, then what is the best way forward? I guess each
entity could have a team ID, but it really doesn't seem like a good
idea. There should be some kind of isolation between the different
teams' data.

Registering a new GAE app for each team is not an option either since
we expect at least hundreds of teams.

So, is there some way to isolate entities from each other within a GAE
datastore?
Also, would it be feasible from a performance point of view to do
this?

Or is simply GAE not the right way to go for this kind of web
offering?

Thanks in advance.

BR, Andreas

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.




[google-appengine] Re: Multiple datastores or share datastore in one app

2009-12-02 Thread andreas_b
Thanks both of you!

Very helpful answers.

Best Regards, Andreas

On Dec 2, 8:24 pm, "Ikai L (Google)"  wrote:
> Creating a database per team is a very heavyweight way to address the
> problem of data segregation. This is unnecessary and in general, not a
> recommended best practice, as you would provide data isolation at the
> application layer. The intuitive solution here is to create an entity group
> for a league or team (depending on your transactional needs) and place child
> entities in that group.
>
> On Tue, Dec 1, 2009 at 10:40 AM, andreas_b wrote:
>
>
>
> > Hi all.
>
> > I'm working on a GWT/GAE project where the idea is to create a portal
> > for sport teams. Each sport team can sign up to get an account where
> > they can register players, keep track of leagues, matches, statistics
> > and so on. Each team should also be able to use their own domain,
> > which automatically should load the site with their configuration when
> > entered (basically just load the gwt-app with some url-parameter that
> > is forwarded to server-side).
>
> > So, coming from a normal SQL-environment, it seems to me that each
> > team that signs up should get their own private database for all their
> > data. As I understand it, this is not possible with GAE datastore?
> > There is a one-to-one mapping between an application and a datastore?
>
> > If this is the case, then what is the best way forward? I guess each
> > entity could have a team ID, but it really doesn't seem like a good
> > idea. There should be some kind of isolation between the different
> > teams' data.
>
> > Registering a new GAE app for each team is not an option either since
> > we expect at least hundreds of teams.
>
> > So, is there some way to isolate entities from each other within a GAE
> > datastore?
> > Also, would it be feasible from a performance point of view to do
> > this?
>
> > Or is simply GAE not the right way to go for this kind of web
> > offering?
>
> > Thanks in advance.
>
> > BR, Andreas
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine" group.
> > To post to this group, send email to google-appeng...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine?hl=en.
>
> --
> Ikai Lan
> Developer Programs Engineer, Google App Engine

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.




[google-appengine] Re: Multiple datastores or share datastore in one app

2009-12-03 Thread andreas_b
So I've spent some time now reading more about the datastore and I
find it hard to get a complete picture about how it works from the gae
docs and articles.
In my case, I must make sure there is some implicit isolation of the
different team's data. So after reading more about entity groups, it
seemed like a good idea
to create a Team entity which is the root entity of an entity group
that contains all the team entities like players, matches, forum posts
etc.
But then I also read the article about datastore contention where it
is recommended that the entity groups are kept as small as possible.

It is likely that lots of forum/comment as well as matches/statistics
entities will be created over time, leading to quite a large entity
group in the case described above.
So now I'm thinking that team data should be divided into several
logical entity groups, BUT, there must still be some "owned"
relationship between all entities that belongs
to a team. Is is possible to have relationships between entity
groups?

I also read that you can specify an app-assigned ID as part of an
entity key. Would it be possible to use a unique team ID as part of
the entity keys?
The goal is of course to let the datastore take care of the security
restraints as much as possible using its build-in features such as
entity groups.
So I'm looking for the optimal way to enforce team data isolation and
avoid any performance/contention pitfalls such as with too large
entity groups.

If you can recommend any in-depth documentation/sample code on these
matters, I would happily look into it.

Thanks!

BR, Andreas



On Dec 2, 8:24 pm, "Ikai L (Google)"  wrote:
> Creating a database per team is a very heavyweight way to address the
> problem of data segregation. This is unnecessary and in general, not a
> recommended best practice, as you would provide data isolation at the
> application layer. The intuitive solution here is to create an entity group
> for a league or team (depending on your transactional needs) and place child
> entities in that group.
>
> On Tue, Dec 1, 2009 at 10:40 AM, andreas_b wrote:
>
>
>
> > Hi all.
>
> > I'm working on a GWT/GAE project where the idea is to create a portal
> > for sport teams. Each sport team can sign up to get an account where
> > they can register players, keep track of leagues, matches, statistics
> > and so on. Each team should also be able to use their own domain,
> > which automatically should load the site with their configuration when
> > entered (basically just load the gwt-app with some url-parameter that
> > is forwarded to server-side).
>
> > So, coming from a normal SQL-environment, it seems to me that each
> > team that signs up should get their own private database for all their
> > data. As I understand it, this is not possible with GAE datastore?
> > There is a one-to-one mapping between an application and a datastore?
>
> > If this is the case, then what is the best way forward? I guess each
> > entity could have a team ID, but it really doesn't seem like a good
> > idea. There should be some kind of isolation between the different
> > teams' data.
>
> > Registering a new GAE app for each team is not an option either since
> > we expect at least hundreds of teams.
>
> > So, is there some way to isolate entities from each other within a GAE
> > datastore?
> > Also, would it be feasible from a performance point of view to do
> > this?
>
> > Or is simply GAE not the right way to go for this kind of web
> > offering?
>
> > Thanks in advance.
>
> > BR, Andreas
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine" group.
> > To post to this group, send email to google-appeng...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine?hl=en.
>
> --
> Ikai Lan
> Developer Programs Engineer, Google App Engine

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.




[google-appengine] Re: Multiple datastores or share datastore in one app

2009-12-03 Thread andreas_b
I chose the wrong wording in my original post. I didn't mean actual
full databases, but something like a schema yes.
Have a lot to learn when it comes to efficient database usage in any
case :-).

Actually I'm not using the LLAPI for portability reasons. I don't want
to build too many dependencies on a particular web service, so
I chose JDO instead, although LLAPI seems a bit more powerful. I might
actually look into it to gain more flexibility.

Thanks for the tip!

BR, Andreas

On Dec 3, 2:19 pm, Roy  wrote:
> In an RDBMS world you would actually create a schema for each team,
> not a full database (unless you have a morbid need to drive your
> sysadmin to an early grave). I did make a feature request for this,
> but you know how it is with GAE feature requests.
>
> If you're using LLAPI, there is actually a very simple trick that will
> work, Append the team name to the kind.
> So instead of a kind called "player", you have kinds called "player-
> spurs", "player-w19an", etc.
>
> You can have a very simple customer data access layer which does this
> automatically based on a session variable.
>
> I use this trick for testing. Whenever I login using a designated test
> username, I append "-test" to my kind names so that I'm not missing
> live and test data in a single dataset.
>
> On Dec 3, 7:53 am, andreas_b  wrote:
>
> > Thanks both of you!
>
> > Very helpful answers.
>
> > Best Regards, Andreas
>
> > On Dec 2, 8:24 pm, "Ikai L (Google)"  wrote:
>
> > > Creating a database per team is a very heavyweight way to address the
> > > problem of data segregation. This is unnecessary and in general, not a
> > > recommended best practice, as you would provide data isolation at the
> > > application layer. The intuitive solution here is to create an entity 
> > > group
> > > for a league or team (depending on your transactional needs) and place 
> > > child
> > > entities in that group.
>
> > > On Tue, Dec 1, 2009 at 10:40 AM, andreas_b 
> > > wrote:
>
> > > > Hi all.
>
> > > > I'm working on a GWT/GAE project where the idea is to create a portal
> > > > for sport teams. Each sport team can sign up to get an account where
> > > > they can register players, keep track of leagues, matches, statistics
> > > > and so on. Each team should also be able to use their own domain,
> > > > which automatically should load the site with their configuration when
> > > > entered (basically just load the gwt-app with some url-parameter that
> > > > is forwarded to server-side).
>
> > > > So, coming from a normal SQL-environment, it seems to me that each
> > > > team that signs up should get their own private database for all their
> > > > data. As I understand it, this is not possible with GAE datastore?
> > > > There is a one-to-one mapping between an application and a datastore?
>
> > > > If this is the case, then what is the best way forward? I guess each
> > > > entity could have a team ID, but it really doesn't seem like a good
> > > > idea. There should be some kind of isolation between the different
> > > > teams' data.
>
> > > > Registering a new GAE app for each team is not an option either since
> > > > we expect at least hundreds of teams.
>
> > > > So, is there some way to isolate entities from each other within a GAE
> > > > datastore?
> > > > Also, would it be feasible from a performance point of view to do
> > > > this?
>
> > > > Or is simply GAE not the right way to go for this kind of web
> > > > offering?
>
> > > > Thanks in advance.
>
> > > > BR, Andreas
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google 
> > > > Groups
> > > > "Google App Engine" group.
> > > > To post to this group, send email to google-appeng...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > google-appengine+unsubscr...@googlegroups.com > > >  e...@googlegroups.com>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/google-appengine?hl=en.
>
> > > --
> > > Ikai Lan
> > > Developer Programs Engineer, Google App Engine

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.