Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of 28 MongoDB Classic interview questions

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

MongoDB is by far the best free and open source NoSQL database for documentation.

If you are preparing for a technical interview with MongoDB NoSQL Database, you'd better take a look at the MongoDB NoSQL interview Q & A below.

These MongoDB NoSQL interview questions and answers cover the basic concepts of NoSQL databases, Replication, Sharding, transactions and locks, tracking and analysis tools (Profiler), Nuances and logging features.

Let's take a look at the following interview questions and answers from the MongoDB NoSQL database:

1. What do you mean by NoSQL database? what's the difference between NoSQL and RDBMS directly? Why use and not use NoSQL databases? What are the advantages of NoSQL database?

NoSQL is a non-relational database, NoSQL = Not Only SQL.

Relational database uses structured data, while NoSQL uses key-value pairs to store data.

When dealing with unstructured / semi-structured big data, expanding horizontally, and dealing with dynamically increasing data items at any time, priority can be given to using NoSQL database.

When considering database maturity, support, analysis and business intelligence, management and professionalism, priority should be given to relational databases.

2. What are the types of NoSQL databases?

Type of NoSQL database

For example: MongoDB, Cassandra, CouchDB, Hypertable, Redis, Riak, Neo4j, HBASE, Couchbase, MemcacheDB, RevenDB and Voldemort are the examples of NoSQL databases. Read it carefully.

3. What is the most basic difference between MySQL and MongoDB?

Both MySQL and MongoDB are free and open source databases. There are many fundamental differences between MySQL and MongoDB, including data representation (data representation), queries, relationships, transactions, schema design and definition, normalization, speed, and performance.

By comparing MySQL and MongoDB, we are actually comparing relational and non-relational databases, that is, different data storage structures. Read in detail

4. How do you compare MongoDB, CouchDB and CouchBase?

Both MongoDB and CouchDB are document-oriented databases. MongoDB and CouchDB are the most typical examples of open source NoSQL databases. They have nothing in common except that they are all stored as documents. There are many differences between MongoDB and CouchDB in data model implementation, interface, object storage, and replication methods.

For details, see the link below:

MongDB vs CouchDB

CouchDB vs CouchBase

5. What is the reason why MongoDB is the best NoSQL database?

The following features make MongoDB the best NoSQL database:

File-oriented query language with high performance, high availability, easy expansibility and rich expansibility

6.What are the nuances of the 32-bit system?

Journaling activates additional memory-mapped files. This further suppresses the database size on the 32-bit version. Therefore, journaling is now disabled by default on 32-bit systems.

7. Will journal playback encounter problems when the entry (entry) is incomplete (for example, there happens to be a midway failure)?

The write operation of each journal (group) is consistent and will not be played back during recovery unless it is complete.

8. What is the role of the parser in MongoDB?

MongoDB includes a database analyzer that displays the performance characteristics of each operation in the database. Through this analyzer you can find queries (or write operations) that are slower than expected; use this information, for example, to determine whether indexes need to be added.

9. What is a namespace?

MongoDB stores BSON objects in collection. Database names and cluster names are linked by periods called namespaces (namespace).

10. If the user removes the attribute of the object, does the attribute be deleted from the storage tier?

Yes, the user removes the attribute and the object is re-saved (re-save ()).

11. Can I use log features for secure backups?

Right.

twelve。 Is a null value allowed for null?

For object members, yes. However, users cannot add null values (null) to database clusters (collection) because null values are not objects. However, the user can add an empty object {}.

13. Update operation immediately fsync to disk?

No, disk writes are delayed by default. The write operation may reach the disk in two or three seconds (60 seconds by default). For example, if the database receives a thousand increments to an object in a second, the disk is refreshed only once. Note that although the fsync option is valid on the command line and through getLastError_old.

14. How to execute a transaction / lock?

MongoDB does not use traditional locks or complex transactions with rollback because it is designed to be lightweight, fast, and predictable high performance. It can be compared to MySQL MylSAM's auto-commit mode. Performance has been improved by streamlining support for transactions, especially in a system that may traverse multiple servers.

15. Why is my data file so large?

MongoDB actively pre-allocates reserved space to prevent file system fragmentation.

16. How long does it take to enable backup failure recovery?

It will take 10 to 30 seconds from the backup database to declare the primary database down to selecting a backup database as the new primary database. During this period, operations on the primary database will fail-- including write and strongly consistent read (strong consistent read) operations. However, you can also execute a final consistency query (eventually consistent query) on the second database (in slaveOk mode), even during that time.

17. What is master or primary?

It is the primary node / member responsible for handling all writes in the current backup cluster (replica set). In a backup cluster, when a failed backup (failover) event occurs, another member becomes primary.

18. What is secondary or slave?

Seconday copies the appropriate operation from the current primary. It does this by tracking replication oplog (local.oplog.rs).

19. Do I have to call getLastError to make sure the write operation works?

No, no. The operation is the same whether you call the getLastError (also known as "Safe Mode") server or not. GetLastError is called only to confirm that the write operation was successfully submitted. Of course, you often want to get confirmation, but the security and effectiveness of the write operation is not determined by this.

20. Should I launch a clustered sharding (sharded) or a non-clustered sharding MongoDB environment?

For ease of development, we recommend starting a MongoDB environment in a non-clustered sharding (unsharded) mode, unless a server is insufficient to hold your initial dataset. Upgrading from non-clustered sharding to clustered sharding (sharding) is seamless, so there is no need to consider sharding when your dataset is not very large.

21. How do sharding and replication work?

Each shard is a logical collection of partition data. Sharding may consist of a single server or a cluster, and we recommend using a cluster for each shard.

twenty-two。 When will the data be extended to multiple shard?

MongoDB fragmentation is based on range. So all the objects in a collection are stored in a chunk. There are multiple options for sharding data only when there is more than one block. Now, the size of each default block is 64Mb, so you need at least 64Mb space to implement a migration.

23. What happens when I try to update a document on a block being migrated (chunk)?

The update operation occurs immediately on the old shard (shard), and then the changes are copied to the new shard before the ownership transfer (ownership transfers).

24. What if I start a query when a shard stops or is slow?

If a shard stops, the query returns an error unless the query sets the "Partial" option. If a shard responds slowly, MongoDB waits for its response.

25. Can I delete the old files in the moveChunk directory?

No problem, these files are temporary files generated during the equalization operation (balancing) of shard. Once these operations have been completed, the relevant temporary files should also be deleted. At present, however, the cleanup work needs to be manual, so please carefully consider freeing up space for these files.

twenty-six。 How do I view the links that Mongo is using?

Db._adminCommand ("connPoolStats")

twenty-seven。 If the block move operation (moveChunk) fails, do I need to manually clear the partially transferred document?

No, the mobile operation is consistent (consistent) and deterministic (deterministic); after a failure, the mobile operation will continue to retry; when completed, the data will only appear in the new shard (shard).

twenty-eight。 If I am using replication technology (replication), can I use journaling in part and not in others?

Sure.

twenty-nine。 What happens when you update a document on a block being migrated (Chunk)?

The update occurs immediately on the old block (Chunk), and then the changes are copied to the new shard before ownership is transferred.

30.MongoDB builds an index on A: {BMagol C}. Will indexes be used for queries A: {BMagol C} and A: {C Magi B}?

No, the index will only be used on A: {Bline C}.

thirty-one。 What happens when a Shard stops or is slow to initiate a query?

If a fragment stops, the query returns an error unless the query has the "Partial" option set. If a shard responds slowly, MongoDB waits for its response.

thirty-two。 Does MongoDB support stored procedures? If you support it, how to use it?

MongoDB supports stored procedures, which are written by javascript and saved in the db.system.js table.

thirty-three。 How to understand the GridFS mechanism in MongoDB, and why does MongoDB use GridFS to store files?

GridFS is a file specification that stores large files in MongoDB. Using GridFS, we can separate large files into multiple small documents, so that we can effectively save large documents and solve the problem of limited BSON objects.

For more information about MongoDB classic interview questions, please see the relevant links below

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report