【发布时间】:2012-10-06 09:46:53
【问题描述】:
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
author = db.get(author_key)
stories_by_author = author.story_set.get()
众所周知;如上例所示,使用 ReferenceProperty 是很好的数据关系解决方案。 所以; 例如,我们的“作者”和“故事”实体(表)中有大量行。多年后,我们删除了“作者”实体或将名称属性替换为另一个名称。 自然;我们的应用程序应该抛出错误。 这种情况(管理代码)是否合理或手动执行关系是否良好?这种情况有什么替代模型吗?
【问题讨论】: