Why not embed the comments in the post itself? You can use JDO embedded
classes or JSON serialization/deserialization.

If you don't go this route, it'll be easier if you have bidirectional keys
because this'll allow you to do a get-by-key on the related entity instead
of a query. A get by key is always faster than a query. Referential
integrity is overrated in this scenario anyway and I wouldn't recommend
using a transaction - what's the worst thing that could happen if one entity
gets out of sync? You can always run a mapreduce job to fix this edge case.

--
Ikai Lan
Developer Programs Engineer, Google App Engine
Blogger: http://googleappengine.blogspot.com
Reddit: http://www.reddit.com/r/appengine
Twitter: http://twitter.com/app_engine



On Thu, Dec 23, 2010 at 11:34 AM, Michael Green <[email protected]>wrote:

> 2 Classes: a Post and a Comment; there is a one to many relationship with
> one Post having many Comments
>
>
>
> I’m thinking of a couple of options
>
>
>
> Option 1: The Post contains a list of keys to a Comment (and the Comment
> does not know directly about which Post it pertains to)
>
>
>
> Option 2: The Comment contains a key to its Post (and the Comment has no
> direct knowledge of Comments)
>
>
>
> In both cases, I would like to have the ability to query in either
> direction.  I think that GAE would support that since (using Option 1 as
> an example) a Comment could always query for Posts containing its key in the
> MVC property.  My question is whether there is a significant performance
> difference between querying in either direction.
>
>
> Note:  I’m avoiding each class having a key to the other to avoid the need
> for a transaction boundary to maintain referential integrity.  Would like to
> hear opinions.  Thanks!
>
> ~Michael
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to