问题描述
我用现有的MongoDB接管了一个项目.我想获取现有数据的可视图像(图表等).显然,与MySQL相比,MongoDB的情况大不相同,但是我想仍然可以看到一些东西吗?
I took over a project with existing MongoDB. I would like to get visual image (diagram etc) of the existing data. Obviously MongoDB is pretty different case compared to MySQL but I guess there is still something that can be visualized?
推荐答案
这确实取决于您对可视化"的要求.通常,关系数据库图最有趣的视觉方面是高级关系和完整性约束(1:1、1:许多,主键,外键等).
This really depends on your requirements for "visualization". Typically most of the more interesting visual aspects of a diagram for a relational database are the high level relationships and integrity constraints (1:1, 1:many, primary key, foreign keys, etc).
MongoDB具有 flexible 模式,从某种意义上说,给定集合中的文档不必遵循预定的格式.这并不意味着基础数据就不能具有某种组织性……只是没有对集合强加任何单一模式(在传统的关系数据库中就是这种情况).
MongoDB has flexible schema, in the sense that documents within a given collection do not have to comply with a predetermined format. That does not mean that the underlying data cannot have some organization .. just that there is no single schema imposed on a collection (as would be the case in a traditional relational database).
在MongoDB中,许多需要可视化的细节需要通过检查集合中的部分或全部文档或通过查看代码来进行分析.
In MongoDB, a lot of the interesting details to visualize will require analysis by inspecting some or all of the documents in a collection OR by reviewing the code.
如果您的应用程序使用的是ODM(对象文档映射器),例如猫鼬(Node.js)或 Morphia (Java),应用程序代码可以提供对预期模式(或至少是最新模式)的快速描述性视图预期模式的版本).适当的语言文档工具(例如jsdoc
或javadoc
)可能有助于生成模型类的合理概述.您可能必须添加一些文档注释才能获得最佳效果.
If your application is using an ODM (Object Document Mapper) such as Mongoose (Node.js) or Morphia (Java), the application code may provide a quick and descriptive view of the intended schema (or at least the latest version of the intended schema). An appropriate language documentation tool such as jsdoc
or javadoc
may be helpful to generate a reasonable overview of your model classes. You will probably have to add some documentation annotations for best results.
模式分析是一种更强力的方法,它涉及查看数据以推断观察到的模式.一种常见的方法是使用地图/缩小.
Schema analysis is a more brute force approach which involves looking at the data in order to infer an observed schema. A common approach for this is to use Map/Reduce.
有一些不同的 mongo
shell 助手会提供您对集合的总体结构有所了解(例如,字段/数据类型及其在源文档中的覆盖范围):
There are a few different mongo
shell helpers that will give you an idea of the general structure of collections (eg. field/data types and their coverage in the source documents):
这些不是视觉上的(在图形意义上),但是模式分析结果的确可以洞悉数据的预期形状和常见变化.
These aren't visual (in the graphical sense), but the schema analysis results do provide insight into the expected shape of the data and common variations.
MongoDB服务器不支持外键关系,从而删除了许多可能有趣的视觉注释.
The MongoDB server does not have support for foreign key relationships, which removes a lot of potentially interesting visual annotations.
创建数据库参考(DBRef) >,但这些遵循的是使用约定,而不是服务器功能.为了使用DBRef确定集合之间的关系,必须扫描集合中的某些或所有文档. variety
或schema.js
尚不支持关系推断.
There are some different client driver approaches to creating Database References (DBRefs), but these are following usage conventions rather than a server feature. In order to determine relationships between collections using DBRefs, some or all of the documents in a collection would have to be scanned. Inference of relationships isn't supported by either variety
or schema.js
yet.
要更好地了解实际内容,可以尝试使用管理之一用户界面.
To get a better idea of the actual content, you could try one of the Admin UIs.
这篇关于从现有MongoDB创建可视化的工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!