Can I create links in the Google App Engine?

Say I have a data warehouse that contains objects of a mother, father, and child. Inside the objects of Mother and Father, I have a field called "child", which stores a link to their child. Is it possible to link this child from mother and father without creating duplicate child copies for each (in the style of OOP). Is this how databases work?

+3
source share
1 answer

Yes, you can use db.ReferenceProperty to do just that.

The reference property simply stores the unique key of the object that it refers to. Thus, mothers and fathers could contain a copy of the key corresponding to their child, as follows:

class Child(db.Model):
    ... # child properties
class Father(db.Model):
    child = db.ReferenceProperty(Child)
    ...
class Mother(db.Model):
    child = db.ReferenceProperty(Child)
    ...
+5
source

Source: https://habr.com/ru/post/1752114/


All Articles