Difference between revisions of "MongoDB Documents"

From mi-linux
Jump to navigationJump to search
Line 6: Line 6:
  
 
You can think of a record in MongoDB as being a document, which is a data structure composed of field and value pairs. 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 record in MongoDB as being a document, which is a data structure composed of field and value pairs. 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 field:value pair format.
 +
 +
Where: name, roomNo, telNo, qualifications and jobTitle are fields and myName, MI412, 2222, ["BSc Computer Science", "MSc Advanced Computing", "PhD NoSQL Databases"] and Senior Lecturer are values

Revision as of 17:56, 18 October 2016

Main Page >> MongoDB >>MongoDB Workbook >> MongoDB Documents

Document Database

MongoDB is an example of a NoSQL Document database. This means in MongoDB, databases hold collections of documents. Each student has their own individual database, where documents can be created.

You can think of a record in MongoDB as being a document, which is a data structure composed of field and value pairs. 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 field:value pair format.

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