NoSQL Flashcards

(51 cards)

1
Q

What types of data do NoSQL databases handle?

A

Unstructured or semistructured data, large volumes of data, high scalability and performance

NoSQL databases are optimized for handling various forms of data that traditional SQL databases may struggle with.

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

What does NoSQL stand for?

A

Non-relational databases

NoSQL databases do not adhere to the traditional relational model.

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

What is an umbrella term for many different database technologies?

A

NoSQL (Not only SQL)

This term encompasses various database types beyond traditional SQL databases.

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

Name three types of NoSQL databases.

A
  • Document stores (e.g., MongoDB, CouchBase)
  • Graph databases (e.g., Neo4J)
  • Key-Value stores (e.g., Redis, Amazon DynamoDB)

Each type serves different use cases and data structures.

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

How do Document stores organize data?

A

As documents (usually in JSON format) grouped in collections

This is different from traditional tables with rows and columns.

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

What is an advantage of using Document stores?

A
  • Can read or write all related data at once
  • No joins or foreign keys, resulting in faster performance
  • Flexible structure allowing easy field modifications
  • Compatible with JSON-like data used in many applications

These advantages make Document stores appealing for certain applications.

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

What is a disadvantage of Document stores?

A
  • Documents can become too large if excessive data is embedded
  • Some databases impose document size limits
  • Lack of fixed schema can lead to messy and inconsistent data

These disadvantages can complicate data management and retrieval.

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

What is MongoDB?

A

A very popular document database

MongoDB utilizes a flexible schema and is widely used in various applications.

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

What format are MongoDB documents stored in internally?

A

BSON format

BSON is a binary representation of JSON-like documents.

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

What is the SQL equivalent of a MongoDB collection?

A

Table

Collections in MongoDB serve a similar purpose to tables in relational databases.

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

What is the SQL equivalent of a MongoDB document?

A

Row

Each document in a MongoDB collection corresponds to a row in a relational database.

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

What is the SQL equivalent of a field (key-value pair) in MongoDB?

A

Column

Fields in MongoDB documents represent the same concept as columns in relational table structures.

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

What is the primary key in a MongoDB document?

A

_id

Every document in MongoDB has a unique identifier, defaulting to ObjectId.

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

Fill in the blank: In MongoDB, documents can be inserted into a collection using the _______ command.

A

insertOne

This command is used to add a single document to a specified collection.

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

What does an embedded document in MongoDB represent?

A

A sub-document

Embedded documents allow for nesting of related data within a single document.

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

What is a potential issue with storing unrelated documents together in a MongoDB collection?

A

It complicates application code handling reads and indexing

Storing unrelated documents can lead to inefficiencies and challenges in data retrieval.

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

What is the main purpose of normalization in Relational DBMS?

A

Eliminates duplication for correctness and consistency

Normalization helps optimize storage in relational databases.

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

Why are joins considered expensive in database operations?

A

They are CPU intensive and contribute to the TCO of database infrastructure

Joins can significantly increase the technical cost of ownership.

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

What is MongoDB optimized for?

A

Compute, as it embeds data that is typically processed together

This design leads to fast reads and writes.

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

What is a benefit of embedding data in MongoDB?

A

Reads and writes become single, atomic operations

This is particularly beneficial for high velocity queries.

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

Provide an example of MongoDB efficiency due to embedding.

A

Reading one document with user and their orders, e.g., Alice’s orders

Example document includes user info and an array of orders.

22
Q

What SQL operation is needed to retrieve orders for a user?

A

A JOIN operation between Users and Orders

Example SQL query demonstrates this operation.

23
Q

What does denormalizing data mean?

A

Storing related data together in one document

This is done to optimize data retrieval.

24
Q

When should you denormalize data?

A

When:
* Data is usually used together
* Contains relationships related to an entity
* One-to-many relationships are always read with parent

Examples include user profiles and blog comments.

25
When should you normalize data?
When: * Denormalization causes duplication without performance gain * Representing complex many-to-many relationships * Embedded documents would become too large ## Footnote Examples include students enrolled in multiple courses.
26
What does CRUD stand for?
Create, Read, Update, Delete ## Footnote These are the four basic operations in a database.
27
What does the operation db.customers.find({last: 'Miller'}) do?
Finds all documents where the field last is 'Miller' ## Footnote This is an example of a read operation.
28
What is the purpose of the projection in a MongoDB query?
To specify which fields to include or exclude in the result ## Footnote For example, setting _id to 0 hides it from the results.
29
What does the query db.fruit_store.find({ qty: { $gt: 4 } }) accomplish?
Finds documents where qty is greater than 4 ## Footnote This demonstrates a basic query operation.
30
Fill in the blank: CRUD stands for _______.
Create, Read, Update, Delete
31
What is the purpose of the update operation in MongoDB?
To modify existing documents in a collection ## Footnote Example: Updating the qty field to 10 for raspberries.
32
How do you delete a document in MongoDB?
Use the deleteOne method with the document's identifier ## Footnote Example: db.fruit_store.deleteOne({ _id: 'raspberries' })
33
What is the MongoDB aggregation framework used for?
To compute sums, averages, min or max values and to group values from multiple documents together
34
What is the input into a MongoDB aggregation pipeline?
The entire collection
35
What is the output of a stage in a MongoDB aggregation pipeline?
The input of the next stage
36
What can stages in a MongoDB aggregation pipeline do?
Filter, sort, group, reshape, and modify documents
37
What does the $match stage do in an aggregation pipeline?
Filters documents based on specific conditions
38
What is the purpose of the $project stage in an aggregation pipeline?
Selects or reshapes fields in the documents
39
What does the $group stage achieve in an aggregation pipeline?
Groups documents by a specified field and performs aggregation
40
What is the function of the $sort stage in an aggregation pipeline?
Sorts documents based on specific fields
41
What type of data structure does MongoDB work best with?
Denormalized data
42
What is the purpose of the $lookup operator in MongoDB?
Performs a left outer join between collections in the same database
43
What is a primary server in MongoDB deployments?
The main server that handles all write operations
44
What are secondary servers in MongoDB deployments?
Backups of the primary server that replicate data from it
45
What is sharding in MongoDB?
A method of handling large data or heavy traffic by splitting data across multiple servers
46
What is the role of the shard key in MongoDB sharding?
Decides how to split the data across shards
47
What is the difference between hashed sharding and ranged sharding?
Hashed sharding spreads data evenly by hashing the shard key, while ranged sharding groups data by sorted ranges of the shard key
48
True or False: NoSQL data can be relational.
True
49
What type of workloads is NoSQL particularly well-suited for?
OLTP workloads (online transaction processing)
50
Fill in the blank: The MongoDB method of handling large data or heavy traffic is called _______.
Sharding
51
What does the aggregation query in MongoDB consist of?
An array of stage documents