MongoDB quick start guide - Arquisoft/citizensLoader_i2b GitHub Wiki
Introduction
MongoDB is an open-source schemaless document database. It's very popular and often referred to as the leading NoSQL database.
The advantage of working with a document database is that you can work with JSON-style documents, and its functionality can be accessed directly through JavaScript notation. Also, the need for expensive joins is reduced.
JSON
JSON (JavaScript Object Notation) is a text format built on two universal data structures, supported in any form in all modern programming languages:
- A collection of key/value pairs (object)
{ string : value, string : value } - An ordered list of values (array)
[ value, value ]
A value can be a string in double quotes, a number, true, false, null, an object or an array. Those structures can be nested.
Differences with Relational DBMS
The folowing table illustrates in a sim MongoDB's main differences with relational databases:
| RDBMS | MongoDB |
|---|---|
| Table | Collection |
| Column | Key |
| Value | Value |
| Record/row | Document/object |
MongoDB is flexible: you can have a collection of Users with an entry (document) with First name and Last name, and then another entry with First name, e-mail address and date of birth. The only requirement for each document is a unique ID number (_id) which Mongo will automatically assign to each document object (although it's not recommended, you could instead set a custom ID).
Installation
We'll see how to easily install and run MongoDB
Download and set-up
MongoDB (community server) can be downloaded here
MongoDB requires a data directory to store data. By default, this directory is \data\db on the same drive from which you start MongoDB. This folder can be created in a Command Prompt with mkdir \data\db.
An alternate path for storing the data files can be defined with "C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --dbpath D:\test\mongodb\data being --dbpath the directory in which you'll save the DB.
Starting MongoDB and connecting
MongoDB can be started running mongod.exe
We can try to connect to MongoDB through the mongo.exe shell, executing it from another Command Prompt
Another useful possibility to interact with the database is using the utility Robomongo, which can be downloaded here
Sources
More information in the Official documentation
Highly recommended video: MongoDB for beginners