Revature MongoDB Flashcards
What does BASE stand for?
Base stands for Basic Availability, Soft-state, Eventual consistency. It describes the fundamental principles of a NoSQL database focusing on scalability, flexibility and high availaility.
What is a database in Mongo?
A database in Mongo is a grouping of unstructured data in JSON format
What is a collection?
Equates to a table
What is a document?
Equates to a row
What rules does Mongo enforce about the structure of documents inside a collection?
In Mongo documents are stored in bson (binary json). The document size cannot be over 16mb and each document in a collection must have a _id
A distributed data store?
A distributed data store stores data across multiple computers. Data can be partitioned or sharded across multiple nodes to improve load balance, allow for scalability and fault tolerance
What is High Availability? How is it achieved in Mongo?
High availability is the ability of a system to operate continuously without failing for a designated period of time. Mongo achieves it through replica sets
What is Scalability? How is it achieved in Mongo?
Scalability is the ability of a database to grow in size. It is achieved both vertically and horizontally in MongoDB. Horizontally through sharding and replica sets
Explain replica sets
A replica set is a group of MongoDB servers that maintain the same data set to provide high availability and redundancy. It ensures that the system can continue to function even if one or more nodes fail.
What are NoSQL databases? What are the different types of NoSQL databases?
NoSQL is a type of nonrelational database query language; Wide column, document, key-value, graph
What kind of NoSQL database MongoDB is?
It is a document database
Which are the most important features of MongoDB?
Can handle unstructured data
What is a Namespace in MongoDB?
The name of the collection, including the database.
Which all languages can be used with MongoDB?
Many popular languanges allow you to interact with MongoDB. Recently we have been using the MongoDB drivers in python to query the database usuing mongoDB query language.
from pymongo import MongoClient
Connect to MongoDB
client = MongoClient(‘mongodb://localhost:27017’)
Select database and collection
db = client[‘myDatabase’]
collection = db[‘myCollection’]
Find all documents
documents = collection.find()
for doc in documents:
print(doc)
Find documents with a specific condition
specific_documents = collection.find({“age”: {“$gt”: 25}})
for doc in specific_documents:
print(doc)
client.close()
Compare SQL databases and MongoDB at a high level.
SQL databases are structured while MongoDB is used to save unstructured data