java - Using Embedd class or storing foreign keys for a Google Datastore? -
this best practice question regarding google datastore. i'm trying build object relationships , i'm seeing 2 options
- directly embed child class @persistent in parent class
- using google key class , store own foreign keys strings in related classes
third option not available, jdo join
app engine not support join queries: cannot query parent entity using attribute of child entity. (you can query property of embedded class, because embedded classes store properties on parent entity. see defining data classes: embedded classes.)
my worry using option 1 simple search query return unneeded data.
example being product class , productdetail class. when customer searches products searching based on category, name , sorted price. of simple info in product class. in productdetail class hold large description strings, links images, lists of key attributes. in product class embed productdetail class or create foreign key property holds key value of productdetail class.
so should use option 2 then? read somewhere don't treat google datastore relational db. in using option 2 i'm doing.
agreed option 1 not scalable because requester not interested in embedded children. jdo , jpa meant perform lazy loading of data on demand there still overhead when no embedded data needed.
option 2 may strictly relational not have be. if entities not locked entity groups via ancestor keys, records unrelated , free of constraints. determine tightness of consistency in entity design , application code.
Comments
Post a Comment