What is affected by ReferenceProperty?
-
29-09-2019 - |
Question
In reference to these two questions (see links below) and the Google AppEngine doc, I got a little bit confused:
class Author(db.Model):
name = db.StringProperty()
class Story(db.Model):
author = db.ReferenceProperty(Author)
story = db.get(story_key)
author_name = story.author.name
Source: Google
The doc example indicates that the object which has the ReferenceProperty
is the "owner" object, which (can have) has such an object as relational item.
The links below show it vice-versa:
The object which has the ReferenceProperty
is the "owned" object.
Now my question is, what is right, or what aspect of the ReferenceProperty
am I missing/misunderstanding?
Solution
The notion of ownership here is purely semantic, ReferenceProperty fields are only used for navigability.
OTHER TIPS
References imply only referentiality - a "has a" relationship, if you like - not ownership. In your example, a Story "has an" Author. Another way to think about it is in the same way you would use a variable to refer to an object in OO.