NoSQL Flashcards
(51 cards)
What types of data do NoSQL databases handle?
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.
What does NoSQL stand for?
Non-relational databases
NoSQL databases do not adhere to the traditional relational model.
What is an umbrella term for many different database technologies?
NoSQL (Not only SQL)
This term encompasses various database types beyond traditional SQL databases.
Name three types of NoSQL databases.
- 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 do Document stores organize data?
As documents (usually in JSON format) grouped in collections
This is different from traditional tables with rows and columns.
What is an advantage of using Document stores?
- 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.
What is a disadvantage of Document stores?
- 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.
What is MongoDB?
A very popular document database
MongoDB utilizes a flexible schema and is widely used in various applications.
What format are MongoDB documents stored in internally?
BSON format
BSON is a binary representation of JSON-like documents.
What is the SQL equivalent of a MongoDB collection?
Table
Collections in MongoDB serve a similar purpose to tables in relational databases.
What is the SQL equivalent of a MongoDB document?
Row
Each document in a MongoDB collection corresponds to a row in a relational database.
What is the SQL equivalent of a field (key-value pair) in MongoDB?
Column
Fields in MongoDB documents represent the same concept as columns in relational table structures.
What is the primary key in a MongoDB document?
_id
Every document in MongoDB has a unique identifier, defaulting to ObjectId.
Fill in the blank: In MongoDB, documents can be inserted into a collection using the _______ command.
insertOne
This command is used to add a single document to a specified collection.
What does an embedded document in MongoDB represent?
A sub-document
Embedded documents allow for nesting of related data within a single document.
What is a potential issue with storing unrelated documents together in a MongoDB collection?
It complicates application code handling reads and indexing
Storing unrelated documents can lead to inefficiencies and challenges in data retrieval.
What is the main purpose of normalization in Relational DBMS?
Eliminates duplication for correctness and consistency
Normalization helps optimize storage in relational databases.
Why are joins considered expensive in database operations?
They are CPU intensive and contribute to the TCO of database infrastructure
Joins can significantly increase the technical cost of ownership.
What is MongoDB optimized for?
Compute, as it embeds data that is typically processed together
This design leads to fast reads and writes.
What is a benefit of embedding data in MongoDB?
Reads and writes become single, atomic operations
This is particularly beneficial for high velocity queries.
Provide an example of MongoDB efficiency due to embedding.
Reading one document with user and their orders, e.g., Alice’s orders
Example document includes user info and an array of orders.
What SQL operation is needed to retrieve orders for a user?
A JOIN operation between Users and Orders
Example SQL query demonstrates this operation.
What does denormalizing data mean?
Storing related data together in one document
This is done to optimize data retrieval.
When should you denormalize data?
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.