These are my notes from MongoDB university free DBA class.
MongoDB works on concept of collection and document.
MySQL | MongoDB
Database = Database
Table = Collection
Row = Document
Column = Field
Table Join = Embedded Documents
Primary Key = Default key _id provide by mongodb itself
MongoDB language is based on JSON Language. No Join / No complex transaction.
JSON
Example : Document/Row
{ _id :"A11",
x :"1",
y:"2",
z:{a,b} --embedding
}
Find id = A11
Example: query
db.collection.find({_id: "A11"})
JSON Types (Java Script Object Notation)
- Pure data exchange format
- Document-Oriented
Quiz : How many data types in Json ?
Ans : 6
- Strings
- Numbers
- Booleans(True\False)
- Null
- Arrays
- Objects/Documents
Left hand side - Only String is a valid type
Quiz
Ans:
Person
{"name" : "John",
"Age" : 25,
"Address" :
{"city" : "New York",
"PostalCode" : 10021
}
"Phone" :
{"Home": "212-555-1234",
"Mobile": "646-555-1234"
}
}
Binary JSON
Fast Scannability
Data types
- Binary Data
- Object ID
BSON Format
-- Mongodb driver
integer = 32 bit (4 bytes)
BSON and Applications
No comments:
Post a Comment