It's hard to answer your question without knowing what your query
profile will be like. Do you often need to display all the purchases
of a user? Or are you just hit-testing them?
In my ecommerce systems:
* Yes, purchases are parented by the User entity. There are a lot of
reasons to do this but the most important is that you can get a
strongly consistent view of the purchases of a single user. Thus, the
user never sees an out-of-date list of their purchases.
* I don't include a Set/List of purchases in the User entity. If you
want a list of them, use an ancestor() query. This isn't a super
common use so I don't worry about the cost of it, and if I did, I'd
probably cache the query result rather than trying to put unbounded
collections into the User object. The User object almost always gets
loaded every time (in my case, every single page request or ajax call)
so keeping it svelte is a good idea.
* Don't use primitive types to track entity references. It may be a
tiny bit cheaper than using Key<?> but you lose all type safety and
you *will* screw it up, producing horrible data corrupting bugs when
you confuse a downloadId with a purchaseId somewhere. Or get some
method parameters backwards.
* "One entity group per user" is almost always the right granularity
for an application. Yes, it generally means that a user can't buy more
than one thing per second, download more than one thing per second,
etc. That's rarely an issue. Entity group transaction limits become
painful when you try to do things like track the number of a product
purchased; it's perfectly reasonable for 100 people to purchase the
same product at the same time.
Jeff
> --
> You received this message because you are subscribed to the Google Groups
> "objectify-appengine" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
objectify-appen...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.