views:

34

answers:

1

Is to possible to create one-to-one relations in the Python version of Google App Engine? I know it is possible in Java.

+3  A: 

Sure - just use a ReferenceProperty that references an entity not referenced by anything else.

Nick Johnson
So there is no way to enforce the constraint
Casebash
I don't believe there is in Java, either. You could have each entity mutually reference the other, and check the reference any time you use it, I suppose. What's your use-case?
Nick Johnson
Java provides it [here](http://code.google.com/appengine/docs/java/datastore/relationships.html#Owned_One_to_One_Relationships). I don't have a use case atm, just seems like a logical thing to have
Casebash
That's an 'owned' relationship, so it's equivalent to a parent entity in Python. Simply creating an entity with parent=other_entity and a known key is equivalent to this.
Nick Johnson