Database Reference
In-Depth Information
"Tracklist": [
{
"Track" : "1",
"Title" : "Smells Like Teen Spirit",
"Length" : "5:02"
},
{
"Track" : "2",
"Title" : "In Bloom",
"Length" : "4:15"
}
]
}
{
"type": "Book",
"Title": "Definitive Guide to MongoDB: A complete guide to dealing with Big Data using
MongoDB 2nd, The",
"ISBN": "987-1-4302-5821-6",
"Publisher": "Apress",
"Author": [
"Hows, David"
"Plugge, Eelco",
"Membrey, Peter",
"Hawkins, Tim ]
}
As you might have noticed when looking at this pair of documents, most of the fields aren't closely related to one
another. Yes, they both have fields called Title and Type ; but apart from that similarity, the documents are completely
different. Nevertheless, these two documents are contained in a single collection called Media .
MongoDB is called a schemaless database, but that doesn't mean MongoDB's data structure is completely devoid
of schema. For example, you do define collections and indexes in MongoDB (you will learn more about this later in
the chapter). Nevertheless, you do not need to predefine a structure for any of the documents you will be adding, as is
the case when working with MySQL, for example.
Simply stated, MongoDB is an extraordinarily dynamic database; the preceding example would never work in a
relational database, unless you also added each possible field to your table. Doing so would be a waste of both space
and performance, not to mention highly disorganized.
Drilling Down on Collections
As mentioned previously, collection is a commonly used term in MongoDB. You can think of a collection as a
container that stores your documents (that is, your data), as shown in Figure 3-1 .
 
Search WWH ::




Custom Search