MongoDB
Theory
- SQL(relational) v s
- NoSQL ()
- What is MongoDB?
- Run on JS Engine
- How does mongoDB work?
- Non-relational Document based
- Advantage and Disadvantages
- BSON
- MongoDB Structure
- MongoDB architecture
- JSON vs BSON
- MongoDB shell
- CRUD Operations
- Cursor, Iterate a Cursor
- Time to Leave
- Maximum Document Size : 16Mb
- Storage engines
- types
- WiredTiger
- ger engine
- In-memory engine
- MMAPv1
- GridFS
- Journal
- Data types in MongoDB (BSON)
- ObjectId
- timestamp
- random value
- incrementing counter
- String
- Int, longInt, Double
- Array, Object
- Boolean
- Date
- Decimal128
- Regex
- Javascript
- with scope
- without scope
- MinKey, MaxKey
- Binary data
- Cursor
- cursor methods
- - toArray
- - forEach
- cursor.allowPartialResults()
- Collection
- db
- db.createCollection(collectionName)
- show collections
- renaming Collection
- Documents
- adding new Documents
- Nested Documents
- advantage
- Inserting Document
- Insert One and Many
- what are the additional methods used for inserting
- Finding / Querying
- find()
- iterate (it)
- pretty()
findOne({<filter>})
- finding In nested Array
field.field
- match
- exact match
- multiple match
- Array
- finding in specific order
- without regard to order
- query by array index
- query by array length
- Projection
- explicitly include fields
- Null,
$type: 10
, $exists
- Filtering
find(<filter>)
find({<filter>}, {<fieldsToGet>})
- Method Chaining
count()
limit()
sort( 1 or \-1 )
skip()
- Operators (denoted by $)
- {$gt: number} $gte
- $lt, $lte
- $eq, $ne
- $or $and $not
- $in: [1,2,3], $nin: [1,2]
- $all
- $set, $unset
- $addToSet
- $elemMatch
- $slice
- $size
- $inc: 1, $inc: -1
- $pull, $push
- $each [ 1, 2 ]
- $eq, $ne
- $currentDate
- $exists
- $expr
- $cond
- $rename
- $min, $max
- $mul
- $ifNull
- $let
- Array Operator
- $push
- $each
- $pull
- $pullAll
- $pop
- $elemMatch
- Deleting
deleteOne({<field:value>})
- deleteMany()
- remove()
- delete vs remove
- Updating
updateOne( {<whichObject>} , {$set: {<field:value>, <field:value>}} )
- Operators
$set
$unset
$rename
- updateMany()
- replaceOne()
- incrementing & decrementing
- adding and remove from array
- upsert
- update() vs updateOne()
- updateOne vs replaceOne
- bulkWrite()
- ordered: false
- ordered vs unordered
- advantages and disadvantages
- Commands
- mongosh
- db
- show dbs
- db.stats
- Aggregation
- How does it work
- advantages
- types of aggregation
- distinct
- Aggregate stages
- $addFields
- $match
- $group
- grouping by
- nested field
- multiple field
- $sort
- $set
- $count
- other ways to count
- client and server side counting
- $limit, $skip
- $merge
- $out
- $project
- $lookup
- $unwind
- $facet
- $fill
- $bucket
- $bucketAuto
- $densify
- $redact
- $search
- allowDiskUse: true
- “$name” vs ”name”
- Accumulator Operators
- $sum, $avg, $max, $min
- Unary Operators
- $type, $lt $gt $or $and $multiply
- Aggregation Pipeline
- How does aggregation pipeline work?
- memory limit : 100mb
- spill to disk
- Batch sizing
- Iterator Size
- Query routing
- Map Reduce
- for what is it used?
- find sum, avg
- Indexes
- pros and cons of Indexes
createIndex({<field: value>})
- options when creating Index
- background: true
- unique: true
- name: “<indexName>”
- getIndex()
- dropIndex(), dropIndexes
- reIndex()
- rename Index
- hiding index
- covered query
- Types of Indexes
- Single Field Index
- Compound Index
- Multikey Index
- Text Index
- Geospatial, Hashed, Clustered Index
- Covered query
- Schema
- pros and cons of using schema
- optional schema
- validation action
- Relationships
- embedding
- referencing
- one-to-one
- one-to-many
- one-to-squillions
- many-to-many
- Replication
- replica set
- advantage and disadvantages of replication
- Replication Architecture
- primary and secondary nodes
- arbiter
- process of election
- heartbeat
- Process of Election
- Replication lag
- operation log (oplog)
- Types of replication
- Asynchronous Replication
- Synchronous Replication
- Majority Commit
- etc…
- Sharding
- advantages and disadvantages
- Sharding Architecture
- What is Mongos/Router
- Config Server
- Types of sharding
- Hashed sharding
- Ranged sharding
- Zone Sharding
- Shard key
- shard hotspots
- normal shard key
- hashed shard key
- Vertical and horizontal scaling
- Zones
- mongos
- auto balancer
- scatter-gather
- Cluster
- types of cluster
- config servers
- Data Modeling
- embedded data model
- reference data model
- linking vs embedding
- Transactions
- How to do transaction
- Session
- startTransaction
- abortTransaction
- commitTransaction
- ACID Transaction
- A - Atomicity
- C - Consistency
- I - Isolation
- D - Durability
- Create view in Mongodb
- CAP Theorem
- theorem
- C - Consistency
- A - Availability
- P - Particle tolerance
- Isolation levels
- Read Concerns
- local
- maojiry
- available
- Write Concerns
- w:1 (Acknowledged)
- w:0 (Unacknowledged)
- majority
- all
- journaled
VS
- $or vs $in
- $all vs $in
- $elemMatch vs $in
- drop() vs remove()
- findAndModify() vs findOneAndUpdate()
- Primary key vs secondary key
- join vs lookup
- dot notation vs nested form
- $currentDate vs $$NOW
- delete() vs remove()
- bulkWrite vs InsertMany
- replace vs update
- shard vs node vs cluster
- Aggregation Pipeline vs Map Reduce
- vertical scalability vs horizontal scalability
- load balancer vs sharding
- odm vs driver
- stage operator vs accumulator operator
- normal shard key vs hashed shard key
- aggregate([$count:”tota”]) vs find({}).count()
- replication vs replica set
- transaction vs query
- scaling up vs scaling down vs scaling out?
- config servers vs mongos
- load balancer vs auto balancer
- countdocument vs count
- What is a MongoDB driver?
- Capped collection and it’s advantages
- Profiler
- Explain
- Soft deleting
Interview Question
- What to do when your quireing becomes slow?
- What to do when your files are getting very big?
- How to condense large volumes of data?
- How to search for text in MongoDB?
- How does MongoDB schema change?
- How can we Backup and Restore in MongoDB?
- What are the pros and cons of Normalising Data in MongoDB
Good to Know
- Atomicity
- Type Bracketing
- Dot Notation
- Cursor behaviour
- Aggregation Pipeline
- Retryable Writes and Reads
- MongoDB CRUD Concepts
- B-Tree
- ACID compliance
- Mongoose
- Network Components
- load balancer
- firewall
- CAP Theorem
- consistency
- availability
- partition tolerance
- Firewall
- Mongo Utilities
- mongoexport
- mongoimport
- mongodump
- mongorestore
- mongostat
- mongotop
- mongooplog
- Clustered collections
- WAL