1
votes

I have table A and AEXT.

I would like to use the same KEY/ID for AEXT as the relationship between table A and table AEXT are 1-1 and as the name suggests AEXT has extended/additional attributes of A.

Can someone please let me know how can I do this in NDB/Python.

Thanks in advance

1
IN addition to the answer you will struggle with appengine datastore until you drop the notion of tables. You have an entity store that you store/retrieve entities via a unique key. In addition you have set independent indexes defined for particular attribute combinations from the entities. - Tim Hoffman

1 Answers

2
votes

Two "tables" (really entity types) can have the same key name as long as they have different paths in the datastore. A path is the kind/name of the entity and all of its ancestors. So for example you could do:

a_key = ndb.Key(A, 'mykey')
aext_key = ndb.Key(AEXT, 'mykey')

Now these keys would be different, but you could construct them again using the same key name, 'mykey'. And once you have the keys, you can grab the entities themselves.

Hope that helps!