MongoDB Support

From ER/Studio Data Architect
Jump to: navigation, search

Go Up to Supported Database Platforms

From ER/Studio Data Architect version 10.0 MongoDB is supported for many operations.

MongoDB is a different type of database, it does not have tables like a relational database, but rather 'collections' which each collection holds a set of documents. Each document (which can be thought of as a 'row' in a relational table) can be in any format, for example JSON format. Different formatted documents can be held in the same collection.

ER/Studio Data Architect supports MongoDB authentication of username and password. No authentication is also supported.

Reverse Engineering

For a walkthrough of reverse engineering MongoDB, please see Reverse Engineer MongoDB Walkthrough.

Forward Engineering

For guidance on how to forward engineering MongoDB, please see Generating a Script File or Database.

Connecting to MongoDB

Ensure that you have network access to your MongoDB server. The default port is 27017 and should be open for incoming connections on the MongoDB server firewall.

The default MongoDB setup on some installations use the BindIP section of the config file to bind the listening port to Unless your ER/Studio Data Architect installation is on the same server, this will need to include the interface that you are connecting to.

The following image shows the default setting. The list is comma separated and so the server network interface would be added to this in the form of:

bind_ip =,

Where is the network address of the MongoDB server.


You can test the connection by using telnet to connect to the port. Verifying that the port is accepting connections by using the following command in a terminal\command window., replacing the with your server's address. The telnet window will go blank if the connection is available.

telnet 27017

To connect with a reverse engineer wizard

  1. From the file menu, click File > New
  2. Select Reverse-engineer an existing database and click Login.
  3. Specify the Database type.
  4. Add the connection details to the Datasource box.
  5. Add authentication details if required by opening the advanced options button.

Mongo reverse page1.png

Notepad blue icon 2.pngNote: Please note that it is possible to complete the reverse engineer wizard on a MongoDB datasource without having permission to do so. However as you do not have permission, nothing will be imported.

Document sampling

Because MongoDB documents can be in any type of format, the documents need to be queried before the DB can be reverse engineered. The Document Sample Size option on Page 2 of the Reverse Engineer wizard allows you to specify how many documents are used for sampling. The default is 100. Should any documents that have a different format not be sampled, the reverse engineer will fail.

Creating Collections

When the reverse engineer takes place, a 'union' of documents create the collection. For example, should one document have additional fields, these will be added to the collection.

Reverse Engineering - Aggregation of document fields
Document 1 Document 2 Collection - author
Field 1 "_id": 2 "_id": 3 _id (PK) - NumberDouble
Field 2 "awards" "awards" awards - Array(Object)
Field 3 "name" name - Object
Field 4 "title" "title" title - String

Nested Objects

Where objects are nested within objects, the wizard creates separate objects that are created with a containment relationship. For example the following JSON object has nested objects within the "name" object:

"name": {
"first": "John",
"last": "Smith"

Magic Wand Icon.pngTip: Separate object creation is useful for improved modeling. For example, nested objects such as address can be shared between different objects rather than duplicated. This also allows modifications to be made to all address fields without having to change each nested item individually.

ID Fields

MongoDB automatically creates an _id field (ObjectID) which you will see added to every collection after a reverse engineer. The exception is objects that are created from nested objects as they are not assigned an _id by MongoDB.

Because of the design of a MongoDB database everything is optional in the related editors, except for the _id field.

See Also