Skip to content

nabin-8/MongoDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MongoDB

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
  1. What is Mongodb?

    Mongodb is a database management system.

    • It allow you to store data.
    • Mongodb is management system to allow query.
  2. Mongodb is it self

    1. Mongo -> Big / humongous
    2. DB -> Database
  3. Why Should learn Mongodb?

    1. To get flexible schema
    2. It is very good at storing huge amount of data
    3. Natively scalable
    4. flexible data, schema
  4. In Sql Databases like RDBMS | mysql / oracal

    • It will only work if its schema is fixed
    • It should have fixed schema
  5. Nosql Databases like Mongodb

  6. Data

    1. Data is called gold / new oil
    2. with data you can computation and generate information
    3. storage

MongoDB

  1. Document oriented
  2. Stores data in the forms of collections and documents
  3. Gained popularity in mid 2000's

Msql | oracle | RDBMS

img

Data is stored in the form of rows

Mongos / MongoDB

flowchart 

A(DATABASE) --> B(Collection) --> C(Row = Document )

Loading

RDBMS AND MONGODB

img

Documents in MongoDB

  1. Similar to JSON
  2. Mango called it BSON
  3. _id is unikely identifier like primary key

Collection in MongoDB

  1. store document

    student Collection BSON looks like

    {
        name:"al",
        age:18,
        status: "D",
        group:["politics", "news"]
    }
    
    

MongoDB Server

  1. In mongodb server you can make many databases
    1. d1, d2, d3, d4
  2. d1 -> can have multiple collections
    1. c1, c2, c3, c4
  3. c1 -> can have multiple documents
    1. d1, d2, d3, d4

Advantages of MongoDB

  1. 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)
    
    Loading

Use case of MongoDB

  1. Produce data management
  2. CMS(content management system)
  3. Operational Intelligence
  4. Online Application

Sharding in MongoDB

flowchart LR

A(Sharding) --> B(Horizentally Scale)

C(Distributing data on multiple machines)

Loading

Raplica sets in MongoDB

  1. Raplica is storing data in more than one machine.

MongoDB is Scalable because

  1. Sharding
  2. Replica sets

How MongoDB stores Data

  1. Mongodb store data in the form of BSON
  2. BSON looks like -> JSON
  3. Binary JSON
  4. It is the binary sirilization over the JSON

Advantages of BSON

  1. Less Space
  2. Faster Traversal
    1. Improve quary speed
  3. Large number of Datatypes

Data Modelling

  • Data Types in MongoDB
  1. Text

    1. String
  2. Numberic

    1. 32-bit integer
    2. 64-bit integer
    3. Double
    4. Decimal128
  3. Data / Time

    1. Data
    2. Timestamp
  4. Others

    1. Object
    2. Array
    3. Binary Data
    4. ObjectID
    5. Boolean
    6. Null
    7. Regular Expression
    8. JavaScript
    9. Min Key
    10. Max Key

Note

  • In MongoDB one document could be 16mb

Data Modeling in MongoDB

flowchart 

   A(Data Modeling)
   A---B(Entities)
   A---C(Relationship)

Loading
  1. Entities Example
    1. Human
    2. Car
  2. Relationship
    1. One to one
    2. one to Many
    3. Many to one
    4. 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)


Loading
  • In database we need to represent these relationship

Embedded Data

  1. Document nested inside another document is the example of embedded data
    1. Entities represent --> In the form of documents
    2. Relationship --> Between two entities
      • If one document is another document / data it represents relationship

References like Foreign Key

flowchart LR

   A(_id:objectid1)<--->B(_id:objectid1 <br> _id:objectid100)
   A<--->C(_id:objectid1 <br> _id:objectid200)
   

Loading

About

MongoDB and Mongoose complete guide

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published