MongoDB:如何在论文中表示模式图?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11323841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 12:43:47  来源:igfitidea点击:

MongoDB: How to represent a schema diagram in a thesis?

mongodbschemanosql

提问by Andrew

I am currently writing a thesis and need to display the schema of my MongoDB in a diagram. I have found no resources about diagrams for document-based databases.

我目前正在写论文,需要在图表中显示我的 MongoDB 的架构。我没有找到有关基于文档的数据库的图表的资源。

There are Entity Relationship Diagrams (ERD) for relational databases. What options do I have for MongoDB? I've noticed that a lot of blogs just display the raw JSON as their "diagram" but this isn't feasible in my thesis.

关系数据库有实体关系图 (ERD)。对于 MongoDB,我有哪些选择?我注意到很多博客只是将原始 JSON 显示为他们的“图表”,但这在我的论文中是不可行的。

Here is a sample of one of my JSON structures:

这是我的 JSON 结构之一的示例:

//MultiChoiceQuestion
{
    "title": "How are you?",
    "valid_answers" : [
        {
            "_id" : ObjectID(xxxx),
            "title": "Great",
            "isCorrect": true,
        },
        {
            "_id" : ObjectID(yyyy),
            "title": "OK",
            "isCorrect": false,
        },
        {
            "_id" : ObjectID(zzzz),
            "title": "Bad",
            "isCorrect": false,
        }
    ],
    "user_responses" : [
        {
            "user": ObjectID(aaaa),
            "answer": ObjectID(xxxx)
        },
        {
            "user": ObjectID(bbbb),
            "answer": ObjectID(xxxx)
        },
        {
            "user": ObjectID(cccc),
            "answer": ObjectID(yyyy)
        }
    ]
}

//User
{
    "_id": ObjectID(aaaa),
    "name": "Person A"
}
//User
{
    "_id": ObjectID(bbbb),
    "name": "Person B"
}
//User
{
    "_id": ObjectID(cccc),
    "name": "Person C"
}

Could this be a possible diagram: Possible Diagram?

这可能是一个可能的图表: 可能的图?

采纳答案by Prasith Govin

We found class diagrams to actually be one of the best ways to represent a mongo schema design.

我们发现类图实际上是表示 mongo 模式设计的最佳方式之一。

It can capture most of the items that a document will have such as arrays, embedded objects and even references.

它可以捕获文档将具有的大多数项目,例如数组、嵌入对象甚至引用。

General guidelines we use to relate onto concepts to uml

我们用来将概念与 uml 相关联的一般准则

Embed= Composition aggregation

嵌入= 组合聚合

Reference= Association class

参考= 关联类

If you're unfamiliar with the uml terminology then this is a decent intro.

如果您不熟悉 uml 术语,那么这是一个不错的介绍。

UML intro from IBM site

来自 IBM 站点的 UML 介绍

回答by dprutean

There is a tool doing diagrams for MongoDb, is called DbSchema. It discovers the schema by scanning data from db. I would also suggest trying two features from them :

有一个为 MongoDb 绘制图表的工具,称为DbSchema。它通过扫描 db 中的数据来发现模式。我还建议尝试他们的两个功能:

  • virtual relations which allow exploring data from different collections in the same time. A kind of JOIN between different collections.
  • HTML documentation, we use it in presentations as well - the comments are in mouse-over ( diarams are saved as vector images ).
  • 允许同时探索来自不同集合的数据的虚拟关系。不同集合之间的一种 JOIN。
  • HTML 文档,我们也在演示文稿中使用它 - 评论在鼠标悬停(diarams 保存为矢量图像)。