GAE 建模关系选项
我需要对以下情况进行建模,但我似乎找不到 关于如何为谷歌应用程序“正确”执行此操作的一致示例 引擎。
假设我遇到如下简单情况:
Company 1 -----> M Store
一家公司拥有一对多商店。每个商店都有一个地址,由以下组成 地址行 1、城市、州、国家、邮政编码等。
好的。假设我们需要创建一个“审计”。审计是为了 公司,并且可以进行一对多的凝视。
就像这样:
Audit 1 ------> 1 Company
1 ------> M Store
现在我们需要根据商店查询所有“审核” “地址”,以便将“审计员”派往正确的地点。
类似这样的文章似乎有很多:
http://code.google.com/ appengine/articles/modeling.html
其中给出了创建“ContactCompany”模型类的示例。 然而他们也说你应该利用这种关系 仅当您“确实需要”并且“关心”性能时。
我还经常读到,你应该尽可能多地非规范化 从而将所有“可查询”数据移至审计中 班级。
那么您建议解决这个问题的最佳方法是什么?
我看到有一个 Expando 类,但我不确定这是否是 对此的“最佳”选择。
对此的任何帮助或想法将不胜感激。
提前致谢, 马特
I need to model the following situation and I can't seem to find a
consistent example on how to do it "correctly" for the google app
engine.
Suppose I've got a simple situation like the following:
Company 1 -----> M Store
A company has one to many stores. Each store has an address made up of
a address line 1, city, state, country, postcode etc.
Ok. Lets say we need to create say an "Audit". An Audit is for a
company and can be across one to many stares.
So something like:
Audit 1 ------> 1 Company
1 ------> M Store
Now we need to query all of the "audits" based on the Store
"addresses" in order to send the "Auditors" to the right locations.
There seem to be numerous articles like this one:
http://code.google.com/appengine/articles/modeling.html
Which give examples of creating a "ContactCompany" model class.
However they also say that you should use this kind of relationship
only when you "really need to" and with "care" for performance.
I've also read - frequently - that you should denormalize as much as
possible thereby moving all of the "query-able" data into the Audit
class.
So what would you suggest as the best way to solve this?
I've seen that there is an Expando class but I'm not sure if that is
the "best" option for this.
Any help or thoughts on this would be totally appreciated.
Thanks in advance,
Matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在您可以查询所有公司商店,
除非是拥有数千家商店的跨国公司,否则此查询在大多数情况下应该可以正常工作。
http://code.google.com/appengine/docs/ python/datastore/entitiesandmodels.html#References
进一步提供帮助。
now you can query for all company store by,
unless it is MNC with thousands of store, this query should work fine in most cases.
http://code.google.com/appengine/docs/python/datastore/entitiesandmodels.html#References
helps further.