对不起,如果这个问题太简单了; 我只进入了9年级.
我正在尝试了解NoSQL数据库设计.我想设计一个最小化读/写次数的Google Datastore模型.
这是博客文章的玩具示例和一对多关系中的评论.哪个更有效 - 将所有注释存储在StructuredProperty中或使用Comment模型中的KeyProperty?
同样,目标是最小化对数据存储的读/写次数.您可以做出以下假设:
使用StructuredProperty:
from google.appengine.ext import ndb
class Comment(ndb.Model):
various properties...
class BlogPost(ndb.Model):
comments = ndb.StructuredProperty(Comment, repeated=True)
various other properties...
Run Code Online (Sandbox Code Playgroud)
使用KeyProperty:
from google.appengine.ext import ndb
class BlogPost(ndb.Model):
various properties...
class Comment(ndb.Model):
blogPost = ndb.KeyProperty(kind=BlogPost)
various other properties...
Run Code Online (Sandbox Code Playgroud)
请尽量提出与有效表示一对多关系相关的任何其他注意事项,以尽量减少对数据存储区的读/写次数.
谢谢.
google-app-engine one-to-many nosql app-engine-ndb google-cloud-datastore