General Flashcards
What is a replica set and what is its purpose?
A replica set is a MongoDB cluster that stores the same data in more than one server and its purpose is to provide redundancy and availability in the event of a server failure
What is a MongoDB cluster?
A MongoDB cluster is a group of MongoDB servers working as a unit
What is MongoDB Atlas and what is its purpose?
MongoDB Atlas is a multi-cloud database platform and its purpose is to simplify deploying and managing databases
How is MongoDB different than MySQL?
- MongoDB is flexible while MySQL is strict
- MongoDB uses collections and BSON documents while MySQL uses tables of rows and columns
What is a document?
A document is a record. It is the basic unit of data in MongoDB
What is a collection?
A collection is a group of documents
What is a database?
A database is a group of collections
What is MongoDB?
MongoDB is a general purpose document database
True or False
Documents in the same collection must have the same field structure and data types
False. Documents in the same collection can have different field structures and data types
What is the difference between BSON and JSON?
BSON is an extension of JSON. BSON supports more data types than JSON
What is BSON?
What is its maximum size?
BSON is a binary-encoded JSON object. It’s maximum size is 16 MB
True or False
MongoDB documents are displayed in JSON and stored as BSON
True
True or False
Documents do not require an _id
field
False. All documents require an _id
field. In fact, if a document is inserted without an _id
field, MongoDB will automatically create an ObjectId
instance for that field
What is the definition of “schema”
Schema is equivalent to “data model”
What feature can be used to put constraints on a flexible schema?
MongoDB schema validation
What is the purpose of a connection string?
The purpose of a connection string is to provide all of the necessary instructions for a client to connect to MongoDB
What is MongoDB Compass and what is its purpose?
MongoDB Compass is a GUI used to query and analyze a MongoDB cluster
What is a MongoDB driver and what is it used for?
A MongoDB driver is a language-specific library used to interact with MongoDB
True or False
A MongoClient
should be created for every query
False. That is an extremely inefficient way of interacting with a database. Only a single MongoClient
instance should be created per application
What is the difference between replaceOne()
and updateOne()
?
replaceOne()
will override the current document’s fields with the ones specified. This means, if the original document had 5 fields but the replacing document only has 1, the new document will only have 1 field. updateOne()
only updates the fields specified by the updating document and does not affect other fields
When are databases and collections first created?
Databases and collections are first created when a document is inserted
What types can be used as the _id field?
Any type other than arrays or null
Is the _id field mutable or immutable?
Immutable
What is the purpose of collation?
The purpose of collation is to specify language-specific rules for string comparisons