No. | TOC | No. | TOC |
---|---|---|---|
1. | mongodb | 7. | mongodb-server |
2. | msql--oracle--rdbms | 8. | advantages-of-mongodb |
3. | mongos--mongodb | 9. | use-case-of-mongodb |
4. | Rdbms-and-mongodb | 10. | sharding-in-mongodb |
5. | documents-in-mongodb | 11. | data-modeling-in-mongodb |
6. | collection-in-mongodb | 12. | embedded-data |
-
What is Mongodb?
Mongodb is a database management system.
- It allow you to store data.
- Mongodb is management system to allow query.
-
Mongodb is it self
- Mongo -> Big / humongous
- DB -> Database
-
Why Should learn Mongodb?
- To get flexible schema
- It is very good at storing huge amount of data
- Natively scalable
- flexible data, schema
-
In Sql Databases like
RDBMS
|mysql
/oracal
- It will only work if its schema is fixed
- It should have fixed schema
-
Nosql Databases like
Mongodb
-
Data
- Data is called gold / new oil
- with data you can computation and generate information
- storage
- Document oriented
- Stores data in the forms of collections and documents
- Gained popularity in mid 2000's
Data is stored in the form of rows |
---|
flowchart
A(DATABASE) --> B(Collection) --> C(Row = Document )
- Similar to JSON
- Mango called it
BSON
- _id is unikely identifier like primary key
-
store document
student Collection BSON looks like
{ name:"al", age:18, status: "D", group:["politics", "news"] }
- In mongodb server you can make many databases
- d1, d2, d3, d4
- d1 -> can have multiple collections
- c1, c2, c3, c4
- c1 -> can have multiple documents
- d1, d2, d3, d4
- Best of SQL and NOSQL
flowchart A(RDBMS) A---AA(Scheme) ---C A---AB(Transection) ---C A---AC(Relationship) ---C B(NO SQL) B---BA(Flexible schema) ---C B---BB(Scalability) ---C C(MongoDB) C---CA(Both of SQL and NOSQL) CA---CAA(Features)
- Produce data management
- CMS(content management system)
- Operational Intelligence
- Online Application
flowchart LR
A(Sharding) --> B(Horizentally Scale)
C(Distributing data on multiple machines)
- Raplica is storing data in more than one machine.
- Sharding
- Replica sets
- Mongodb store data in the form of
BSON
- BSON looks like ->
JSON
- Binary JSON
- It is the binary sirilization over the JSON
- Less Space
- Faster Traversal
- Improve quary speed
- Large number of Datatypes
- Data Types in MongoDB
-
Text
- String
-
Numberic
- 32-bit integer
- 64-bit integer
- Double
- Decimal128
-
Data / Time
- Data
- Timestamp
-
Others
- Object
- Array
- Binary Data
- ObjectID
- Boolean
- Null
- Regular Expression
- JavaScript
- Min Key
- Max Key
- In MongoDB one document could be 16mb
flowchart
A(Data Modeling)
A---B(Entities)
A---C(Relationship)
- Entities Example
- Human
- Car
- Relationship
- One to one
- one to Many
- Many to one
- Many to Many
- Example
flowchart LR
A(Citizen)--- to ---B(citizinship)
C(Country)--- To ---D(citizen)
E(citizen)--- 2 ---F(Country)
G(students)--- two ---H(teachers)
- In database we need to represent these relationship
- Document nested inside another document is the example of embedded data
- Entities represent --> In the form of documents
- Relationship --> Between two entities
- If one document is another document / data it represents relationship
flowchart LR
A(_id:objectid1)<--->B(_id:objectid1 <br> _id:objectid100)
A<--->C(_id:objectid1 <br> _id:objectid200)