MongoDB
MongoBD is NoSQL document database. MongoDB is single master model and has a number of slave nodes. If master goes down, one of the slaves will be master. This is done automatically but it will tale 10-30 seconds.
Term | Description | Example |
---|---|---|
Databse | Contains collections | airbnb.db |
Collections | A collection is a group of documents. In RDBMS, this is a TABLE. | User, Booking, Room |
Documents | Contains basic unit of information. | { firstName: "Kei", lastName: "Oka" } |
Namespace | Concatenation of the database name and collection name. | school.student |
https://www.youtube.com/watch?v=UFVFIKduXpo
Indexes
By default MongoDB creates the _id property which is index. Without indexes, MongoDB must scan collection (called collection scan). If mongoDB can use index, querying is done efficiently. Array filed puts indexes on each value of itself.
Covered query
Journaling
Sharding
Sharding is a method for distributing data across multiple machines. MongoDB uses sharding to support deployments with very large data sets and high throughput operations.
https://www.youtube.com/watch?v=W3HhqMvwZP8
https://www.youtube.com/watch?v=UFVFIKduXpo&t=521s
List all databases
show dbs
Create Database
use exampledb;
Create Index
https://docs.mongodb.com/manual/indexes/
https://www.tutorialspoint.com/mongodb/mongodb\_interview\_questions.htm