Basics: MongoDB
Getting Started...
A document is the basic unit of data for MongoDB = Row in RDBMS
Similarly, a collection can be thought of as a table with a dynamic schema.
A single instance of MongoDB can host multiple independent databases, each of which can have its own collections.
Every document has a special key, "_id", = Primary Key
MongoDB comes with a simple but powerful JavaScript shell.
Document: an ordered set of keys with associated values. = Map or Dictionary
key: value
Ex: {"greeting" : "Hello, world!"}
IMP. The keys in a document are strings. Any UTF-8 character is allowed in a key, with a few notable exceptions:
• Keys must not contain the character \0 (the null character). This character is used to signify the end of a key.
• The . and $ characters have some special properties and should be used only in certain circumstances. In general, they should be considered reserved, and drivers will complain if they are used inappropriately.
- MongoDB is type-sensitive and case-sensitive. For example, these documents are distinct:
{"foo" : 3} // string:num {"foo" : "3"} //string:string
as are as these:
{"foo" : 3} {"Foo" : 3}
MongoDB cannot contain duplicate keys.
A collection is a group of documents.