MongoDB关系

发布于 2024-11-07 11:10:45 字数 634 浏览 0 评论 0原文

拜托,你能说我,觉得我好还是坏?

我有两个对象,ExhibitionStand。在我的逻辑中,Exhibition has_many Stands。 我想使用 mongodb。首先,我可以做嵌入展览的展台。但多个展览可以包含同一个展位。之后我认为,最好创建两个文档(集合):ExhibitionStand 并模仿关系引用。

     1.Is it good idea?

如果这是个好主意,我会在展览文档字段stand_ids中创建,该字段将是数组,我将在该字段中推送必要的展位ID。

     2.When i push ids in Exhibition and after this i 
       want to delete reference stand in Stands document. 
       How will be better to destroy id in Exhibition.stand_ids.

     3.Think i by relational or it is good practice?

Please, can you say me, think i good or bad?

I have two objects, Exhibition and Stand. In my logic Exhibition has_many Stands.
I want to use mongodb. First, i can do Stand embedded in Exhibition. But several exhibitions can include same stand. After this i think, that will be better to create two documents(collections): Exhibition and Stand and imitate relation references.

     1.Is it good idea?

If it is good idea, than i create in Exhibition document field stand_ids, which will be array and i will push in this field necessary stand ids.

     2.When i push ids in Exhibition and after this i 
       want to delete reference stand in Stands document. 
       How will be better to destroy id in Exhibition.stand_ids.

     3.Think i by relational or it is good practice?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

帥小哥 2024-11-14 11:10:45

如果您正在处理关系,则应该使用关系数据库。如果您的数据具有结构,那么使用 noSQL 解决方案就没有意义。

我给您的建议是使用最适合该工作的工具。您尝试做的事情似乎对于关系数据库来说是理想的。

If you're working with relations you should use a relational DB. It doesn't make sense to use a noSQL solution if your data has structure.

My advice to you would be to use the tool most suited for the job. What you're trying to do seems to be ideal for a relational DB.

-黛色若梦 2024-11-14 11:10:45
class Exhibition
  embeds_many :stands
end

class Stand
  embedded_in :exhibition
end

在每个类中使用上述关系。

class Exhibition
  embeds_many :stands
end

class Stand
  embedded_in :exhibition
end

use above relationship in each of the class.

瀟灑尐姊 2024-11-14 11:10:45

我认为这篇文章适合您 http://www.mongodb.org/display/ DOCS/架构+设计

用例

客户/订单/订单行项目

订单应该是一个集合。客户集合。 line-items 应该是嵌入在订单对象中的 line-items 数组。

博客系统。

帖子应该是一个集合。帖子作者可能是一个单独的集合,或者只是帖子中的一个字段(如果只有电子邮件地址)。为了提高性能,评论应该嵌入帖子中的对象。

架构设计基础知识

Kyle Banker,10gen

http://www.10gen.com/presentation/mongosf2011/schemabasics< /p>

索引&查询优化
Alvin Richards,企业工程高级总监

http://www.10gen.com/presentation/ mongosf-2011/mongodb-索引-查询-优化

*这 2 个视频是 mongoddb 上见过的最好的视频

I think this post will be right for you http://www.mongodb.org/display/DOCS/Schema+Design

Use Cases

Customer / Order / Order Line-Item

Orders should be a collection. customers a collection. line-items should be an array of line-items embedded in the order object.

Blogging system.

Posts should be a collection. post author might be a separate collection, or simply a field within posts if only an email address. comments should be embedded objects within a post for performance.

Schema Design Basics

Kyle Banker, 10gen

http://www.10gen.com/presentation/mongosf2011/schemabasics

Indexing & Query Optimization
Alvin Richards, Senior Director of Enterprise Engineering

http://www.10gen.com/presentation/mongosf-2011/mongodb-indexing-query-optimization

*These 2 videos are the bests on mongoddb ever seen imho

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文