This is a best practice question regarding the Google Datastore. I'm trying to build object relationships and I'm seeing two options
- Directly embed a child class with @Persistent in the parent class
- Using the Google Key class and store my own foreign keys as strings in related classes
Third option is not available, JDO join
App Engine does not support join queries: you cannot query a parent entity using an attribute of a child entity. (You can query a property of an embedded class, because embedded classes store properties on the parent entity. See Defining Data Classes: Embedded Classes.)
My worry about using option 1 is that a simple search query I would return to much unneeded data.
Example being a Product Class and ProductDetail Class. When a customer searches my products they are just searching based on Category, Name and sorted by price. All of the simple info is in the Product class. In the ProductDetail class I hold large description strings, links to images, lists of key attributes. So in the Product Class I could embed the ProductDetail class or just create a foreign key property that holds the key value of the ProductDetail class.
So should I use option 2 then? I read somewhere don't treat the Google datastore like a relational DB. But in using option 2 that is just what I'm doing.