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.
For a walkthrough of reverse engineering MongoDB, please see Reverse Engineer MongoDB Walkthrough.
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 127.0.0.1. 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 = 127.0.0.1,10.150.100.90
Where 10.150.100.90 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 10.150.100.90 with your server's address. The telnet window will go blank if the connection is available.
telnet 10.150.100.90 27017
To connect with a reverse engineer wizard
- From the file menu, click File > New
- Select Reverse-engineer an existing database and click Login.
- Specify the Database type.
- Add the connection details to the Datasource box.
- Add authentication details if required by opening the advanced options button.
Note: 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.
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.
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.
|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|
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:
Tip: 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.
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.