views:

35

answers:

2

In reference to this 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/missunderstanding. regards,

+1  A: 

The notion of ownership here is purely semantic, ReferenceProperty fields are only used for navigability.

Claude Vedovini
So it just have to exist in one Model, and just represents a link, it is not important where it has to be plaeced?
daemonfire300
absolutely! it all depends on how convenient it is for you.
Claude Vedovini
+1  A: 

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.

Nick Johnson