Difference between revisions of "MongoDB Overview"

From mi-linux
Jump to navigationJump to search
 
(10 intermediate revisions by one other user not shown)
Line 11: Line 11:
 
== Collection ==
 
== Collection ==
  
MongoDB stores its documents in a collection. A collection can hold one or more document. Collections can be compared to tables in a relational database.
+
MongoDB stores its documents in a collection. A collection can hold one or more documents. Collections can be compared to tables in a relational database.
  
 
The main difference to a relational database is that MongoDB does not support joins or transactions.
 
The main difference to a relational database is that MongoDB does not support joins or transactions.
Line 17: Line 17:
 
== Document ==
 
== Document ==
  
You can think of a document in MongoDB as being a record or row in a relational table. The document has a data structure composed of field and value pairs, which correspond to a column in a relational table. MongoDB documents are similar to JSON objects. The documents can be complex, where the values of fields can include other documents, arrays and arrays of documents.
+
You can think of a document in MongoDB as being a record or row in a relational table. The document has a data structure composed of field and value pairs (enclosed in curly bracket {}), which correspond to a column in a relational table. MongoDB documents are similar to JSON objects. The documents can be complex, where the values of fields can include other documents, arrays and arrays of documents.
  
 
For example, a record for a lecturer could be:
 
For example, a record for a lecturer could be:
Line 31: Line 31:
 
</pre>
 
</pre>
  
This follows a <b>key:value</b> pair format.
+
This follows a '''{key:value}''' pair format.
  
Where: name, roomNo, telNo, qualifications and jobTitle are keyss and myName, MI412, 2222, ["BSc Computer Science", "MSc Advanced Computing", "PhD NoSQL Databases"] and Senior Lecturer are values.
+
Where:  
 +
*''name, roomNo, telNo, qualifications, jobTitle'' are keys
 +
* ''"myName", "MI412", "2222", ["BSc Computer Science", "MSc Advanced Computing", "PhD NoSQL Databases"], "Senior Lecturer"'' are values
  
 +
== SQL? ==
  
== SQL? ==
+
MongoDB does not support SQL, however, it can be used by a variety of languages.
 +
 
 +
The mongo shell installed on mi-linux uses Javascript to access the database.
 +
 
 +
Typical format for a command is:
 +
<pre style="color:blue">
 +
db.functionName(optional_list_of_parameters);
 +
</pre>
  
MongoDB does not support SQL. It can be used by a variety of languages, the version installed on mi-linux uses Javascript to access the database.
+
Where db is a global variable that defaults to the current database.
  
 
== Next Step ==
 
== Next Step ==
  
Return to the [[MongoDB_Workbook|Workbook]].
+
[[MongoDB_URLs|Useful]] URLs.

Latest revision as of 14:59, 17 February 2019

Main Page >> MongoDB >>MongoDB Workbook >> MongoDB Overview

MongoDB is an example of a NoSQL Document Database. It works on concept of collections and documents.

Database

In MongoDB, databases hold collections of documents. Our MongoDB server supports lots of databases, since each student has their own individual database, where documents can be created.

Note: you do not need to create a database, it will be setup for you as part of the registration process.

Collection

MongoDB stores its documents in a collection. A collection can hold one or more documents. Collections can be compared to tables in a relational database.

The main difference to a relational database is that MongoDB does not support joins or transactions.

Document

You can think of a document in MongoDB as being a record or row in a relational table. The document has a data structure composed of field and value pairs (enclosed in curly bracket {}), which correspond to a column in a relational table. MongoDB documents are similar to JSON objects. The documents can be complex, where the values of fields can include other documents, arrays and arrays of documents.

For example, a record for a lecturer could be:

 {
    name: "myName",
    roomNo: "MI412",
    telNo:  "2222"
    qualifications: ["BSc Computer Science", "MSc Advanced Computing", "PhD NoSQL Databases"]
    jobTitle: "Senior Lecturer"
 }

This follows a {key:value} pair format.

Where:

  • name, roomNo, telNo, qualifications, jobTitle are keys
  • "myName", "MI412", "2222", ["BSc Computer Science", "MSc Advanced Computing", "PhD NoSQL Databases"], "Senior Lecturer" are values

SQL?

MongoDB does not support SQL, however, it can be used by a variety of languages.

The mongo shell installed on mi-linux uses Javascript to access the database.

Typical format for a command is:

 db.functionName(optional_list_of_parameters);

Where db is a global variable that defaults to the current database.

Next Step

Useful URLs.