views:

58

answers:

2

A quick question, Does google app's datastore support foreign key mapping, if yes, can anyone enlightened me XD, or share some link.

thank you very much,

A: 

You can use ReferenceProperty to refer to other items of different Kind, or SelfReferenceProperty to refer to other items of the same Kind.

Amber
A: 

All entities have a key, which you can reference and store in an entity's property. Note that holding a key to an entity doesn't imply that the entity pointed to actually exists - i.e. there is no relational integrity. Similarly, removing an entity that exists doesn't have any effect on the key.

A similar SQL construct would be a table with a column that holds a value that is a primary key elsewhere, but without a foreign key relationship and therefore no relational integrity.

There is a concept of a dependent child with cascading delete. This is a JDO construct and not natively supported by the datastore itself - the delete is managed by the higher-level JDO framework.

You can also use embedded classes. An embedded object is essentially contained by the holding object store as a normal property. If you delete the holding class, you delete the embedded object.

http://code.google.com/appengine/docs/python/datastore/keyclass.html http://code.google.com/appengine/docs/java/datastore/relationships.html#Dependent_Children_and_Cascading_Deletes http://code.google.com/appengine/docs/java/datastore/dataclasses.html#Embedded_Classes

Richard Watson