Database Reference
In-Depth Information
comparable to a row in SQL. In the following example, you will see how two completely
different types of documents can coexist in a single collection named Media (note that a
collection is roughly equivalent to a table in the world of SQL):
{
"Type": "CD",
"Artist": "Nirvana",
"Title": "Nevermind",
"Genre": "Grunge",
"Releasedate": "1991.09.24",
"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.
 
Search WWH ::




Custom Search