如何使用 UML 绘制 NoSQL 数据库(面向文档)? [英] How to draw a NoSQL database (document oriented) with UML?

查看:33
本文介绍了如何使用 UML 绘制 NoSQL 数据库(面向文档)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 NoSQL 使用的初学者,目标是构建一个类似 uber 的数据库.是否可以使用 UML 绘制 CouchDB 数据库(面向文档),特别是如何进行连接?或者还有其他更适合 NoSQL 数据库建模的替代方案吗?

I'm beginner in the use of NoSQL and aim to build a uber-like database. Is it possible to draw a CouchDB database (document oriented) with UML and in particular, how to do joins? Or is there another alternative better suited for NoSQL database modeling?

推荐答案

您可以使用 UML 类图对应用程序域的实体和聚合进行建模,而不管实现技术如何.您还可以对使用 NoSQL 数据库,尤其是 文档存储,例如 CouchDB.存储在数据库中的对象是一种脱水(即没有其行为的对象数据)到一个文档中.

You can use UML class diagrams to model entities and aggregates of an application domain, regardless of the implementation technology. You can also model a more concrete implementation that uses a NoSQL database, and in particular document stores such as CouchDB. Objects are stored in the database are kind-of dehydrated (i.e. object data without their behavior) into a document.

您将面临挑战:

  1. document 世界和对象世界之间的映射:一个 <强>文档可能包含多个相关对象(无需连接),以及指向其他对象的链接(另请参阅嵌入/嵌套文档与文档引用).

  1. mapping between the document world and the object world: a document may contain several related objects (no joins needed), as well as links to other objects (see also embedded/nested document vs. document references).

潜在的非结构化(或松散结构)文档:文档数据库对文档内容极为灵活,完全允许将完全不相关的类的对象混合到同一个文档集合中.此外,文档的字段/属性/成员可能是动态的和演变的.然而,在实践中,集合通常包含类似的对象,这些对象主要在字段方面有所不同(例如,确认隐式类的存在).文档甚至可以根据 以确保在需要时保持一致性.

potentially unstructured (or loosely structured) documents: document databases are extremely flexible about the content of documents, and it is perfectly allowed to mix objects of completely unrelated classes into the same document collection. Moreover, the fields/properties/members of a document may be dynamic and evolve. In practice however, collections often contain similar objects that will vary mainly regarding the fields (for example to acknowledge existence of implicit classes). Documents may even be validated according to a schema to ensure consistency if needed.

UML 类基于强类型,而文档中的类型与其内容的其余部分一样灵活(例如,字段 from 可以是日期 2000-04-02 在一个文档中或字符串 a long time ago" 在另一个文档中).

UML classes are based on strong typing, whereas types in documents are as flexible as the rest of their content (e.g. a field from could be a date 2000-04-02 in one document or a string "a long time ago" in another one).

因此,在开始之前,您需要考虑映射策略.我的建议是在 UML 中专注于对象模型的设计,并将文档视为相关文档的方便分组(DDD 聚合 可能在这方面有所帮助).以下经验法则可能有助于建模:

So before you start, you need to think of the mapping strategy. My advice would be to focus in UML on the design of your object model, and think of documents as a convenient grouping of related ones (DDD aggregates may help in this regard). The following rule of thumb may help for the modeling:

  • 连接(例如独立文档之间的链接)将由关联表示.
  • 对象与其他对象的系统分组,可能表明存在某种更强的关系,例如 UML 组合.
  • 因文档而异的字段将用可选属性(多重性0..10..*)或封闭的泛化/特化表示对象,取决于解释变化的逻辑.
  • joins (e.g. links between independent documents) will be represented by associations.
  • systematic grouping of objects with other, may suggest existence of some kind of stronger relation such as UML composition.
  • fields that vary from document to document would be represented either with optional properties (multiplicity 0..1 or 0..*) or generalisation/specialization of the enclosing object, depending on the logic that explains the variation.

这篇关于如何使用 UML 绘制 NoSQL 数据库(面向文档)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆