Revature MongoDB Flashcards

1
Q

What does BASE stand for?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a database in Mongo?

A

A database in Mongo is a grouping of unstructured data in JSON format

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a collection?

A

Equates to a table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a document?

A

Equates to a row

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What rules does Mongo enforce about the structure of documents inside a collection?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

A distributed data store?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is High Availability? How is it achieved in Mongo?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Scalability? How is it achieved in Mongo?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Explain replica sets

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are NoSQL databases? What are the different types of NoSQL databases?

A

NoSQL is a type of nonrelational database query language; Wide column, document, key-value, graph

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What kind of NoSQL database MongoDB is?

A

It is a document database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which are the most important features of MongoDB?

A

Can handle unstructured data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a Namespace in MongoDB?

A

The name of the collection, including the database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which all languages can be used with MongoDB?

A

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()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Compare SQL databases and MongoDB at a high level.

A

SQL databases are structured while MongoDB is used to save unstructured data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How is MongoDB better than other SQL databases?

A

It is much faster than other SQL databases; Much more scalable; More flexible

17
Q

Does MongoDB support foreign key constraints?

A

No, this is because it is a noSQL document database that utilizes keys and value pairs

18
Q

Does MongoDB support ACID transaction management and locking functionalities?

A

Yes it does. This is done through multi document Acid transaction and document level locking.

19
Q

How can you achieve primary key - foreign key relationships in MongoDB?

A

By embedding a document inside another

{
“_id”: 1,
“name”: “Order 1”,
“items”: [
{ “product_id”: 101, “quantity”: 2 },
{ “product_id”: 102, “quantity”: 1 }
]
}

20
Q

When should we embed one document within another in MongoDB?

A

When we want to relate the two documents

21
Q

Mention what is ObjectId composed of?

A

4-byte timestamp value representing object’s creation; 5-byte random value; 3-byte incrementing counter

22
Q

What is a distributed application

A

A distributed application is a software application that runs on multiple computers or nodes within a network as a unified system. It allows for fault tolerence, scalability and concurrency