Nosql database interview questions
NoSQL, standing for “not only SQL,” refers to databases that store and manage data differently than relational databases. NoSQL databases are designed to handle unstructured data and are known for their flexibility. They can be categorized into four main types: document, key-value, wide-column, and graph databases.
Key Features:
Unstructured Data: NoSQL is suitable for unstructured or semi-structured data.
Scalability: These databases offer horizontal scalability.
Schema-less: NoSQL databases do not require a fixed schema.
Database transactions imply ACID properties, where “I” stands for isolation and concurrency control. ( Used to control deadlock )
The (serializable) isolation property ensures that the result of concurrently executed transactions is the same as if they had been executed in some serial order.
Many DBMSs provide weaker isolation levels for performance reasons, leaving it up to the application developer to choose the proper one. Moreover, a weaker isolation level is often the default in monolithic databases, e.g., “read committed” in PostgreSQL and MySQL. Meanwhile, stronger defaults prevail in distributed databases: “repeatable read” in YugabyteDB and TiDB and “serializable” in CockroachDB and [YDB]YDB.
Difference between Relational database and NoSQL
| Relational Database | NoSQL |
| It is used to handle data coming in low velocity. | It is used to handle data coming in high velocity. |
| It gives only read scalability. | It gives both read and write scalability. |
| It manages structured data. | It manages all type of data. |
| Data arrives from one or few locations. | Data arrives from many locations. |
| It supports complex transactions. | It supports simple transactions. |
| It has single point of failure. | No single point of failure. |
| It handles data in less volume. | It handles data in high volume. |
| Transactions written in one location. | Transactions written in many locations. |
| support ACID properties compliance | doesn’t support ACID properties |
| It’s difficult to make changes in database once it is defined | Enables easy and frequent changes to database |
| Schema is mandatory to store the data | Schema design is not required |
| Deployed in vertical fashion. | Deployed in Horizontal fashion. |
MongoDb
Mongodb atlas is cloud service provided by AWS
Notes :
1) Collections .
Collections are like tables in Mongodb .
Capped collections in MongoDB are fixed-size, high-performance collections that operate like circular buffers. They automatically overwrite the oldest documents with new data once the allocated size is filled. They maintain strict insertion order, allowing fast, sequential writes and supporting tailable cursors for real-time data streaming
Commands :
1) mongo - to check details of installed software
mongod --auth
mongo -- help -- mongodb connecion utility . mongo --host ipadd -- port portnumber
2) ps -ef | grep mongod -- to check if mongodb process is running
netstat -ntpl
3) systemctl start mongod -- to start mongodb ( with root )
4) systemctl sttaus mongod
5) systemctl enable mongod - enable auto start
6) mongod --> db.version() , show dbs ,
7) crude operation --Dml
db.collection.insertOne() , db.movies.insertone({"tittle":"Godzilla"})
8) enable auditing
mongod --dbpath/data/db--auditDestinationfile --auditFormatBSON --auditPathdata/db/auditLog.bson
Files :
1) /etc/mongod.conf -- authorization : enabled
2) /var/log/mongodb/mongod.log
3)
Database creation :
1) show dbs
2) use db_name
3) db.createcollection("movienames")
4) show collections
5) use db_name --> db.dropDatabase()
6)
Backup and Recovery Utilities
•mongoexport
•Mongoimport
•mongodump
•mongorestore
Editions of MongoDB
•MongoDBCommunity Edition ( Free for Production use)
•MongoDBEnterprise Advanced Server ( Paid License)
•MongoDBAtlas ( For Cloud)
•MongoDBRealm for mobile applications
•Upgrading from community edition to enterprise Edition possible
Difference Between Community and Enterprise Edition
•MongoDBEnterprise provides various features not available in the MongoDBCommunity edition, such as:
•In-Memory Storage Engine
•Auditing
•Kerberos Authentication
•LDAP Proxy Authentication and LDAP Authorization
•Encryption at Rest
MongoDB deployment Models
•Standalone
•Standalone installation is a single-machine installation and is meant mainly for development or experimental purposes.
•Replica set
•A replica set in MongoDBis a group of processes or servers that work together to provide data redundancy and high availability. It requires at least three servers in a cluster. These servers are configured as the primary, secondaries, or arbiters.
•Sharded
•Shardeddeployments allow you to store the data in a distributed way. A shard contains a subset of the data, and each shard must use a replica set to provide redundancy of the data that it holds. Multiple shards working together provide a distributed and replicated dataset.
This beta is designed for learners who’ve completed all the following MongoDB Skill Badges:
CRUD Operations in MongoDB
MongoDB Indexing Design Fundamentals
Optimizing and Maintaining MongoDB Cluster Reliability
Data Resilience in MongoDB Self-Managed Deployments
MongoDB Sharding Strategies
MongoDB Aggregation Fundamentals
MongoDB Query Optimization Techniques
Monitoring MongoDB with Built-in Tools
Securing MongoDB Self-Managed: Authentication & Authorization
MongoDB Overview: Core Concepts and Architecture
Optimizing MongoDB Performance with Tuning Tools
Securing MongoDB Self-Managed Networking
MongoDB Encryption at Rest with BYOK
References :
https://blog.ydb.tech/do-we-fear-the-serializable-isolation-level-more-than-we-fear-subtle-bugs-5a025401b609
Comments
Post a Comment