NoSQL Exam Answer Key
NoSQL Exam Answer Key
NoSQL stands for 'Not Only SQL'. It refers to non-relational database systems designed to
handle large volumes of data, high velocity, and a variety of data types. Unlike relational
databases that store data in tables with fixed schemas, NoSQL databases store data in
flexible formats like documents, key-value pairs, or graphs. They allow for horizontal
scaling and better performance in distributed systems.
NoSQL uses a denormalized and schema-less approach, allowing embedded documents and
arrays, which improves performance. In contrast, relational databases use strict schemas
with normalized tables and relationships.
Sharding is the process of breaking a large dataset into smaller, more manageable pieces
called shards, distributed across multiple servers. It helps improve performance and
scalability.
9. What is the CAP theorem, and how does it relate to NoSQL databases?
CAP theorem states that a distributed database can only guarantee two out of the following
three: Consistency, Availability, and Partition Tolerance. NoSQL databases often choose
Availability and Partition Tolerance over strict consistency.
10. Name two popular NoSQL databases and their use cases.
Indexing improves query performance by creating data structures that allow the database
to locate data quickly without scanning the entire collection. For example, MongoDB
supports single field, compound, and text indexes.
12. What is the difference between sharding and replication in NoSQL databases?
It ensures that documents follow a specified structure or rules, helping maintain data
integrity and consistency.
15. What are some common tools used for drawing database models?
- Lucidchart
- Draw.io
- ERDPlus
- dbdiagram.io
Use: `db.oldCollectionName.renameCollection('newCollectionName')`
19. Suppose you are designing a NoSQL database for an e-commerce platform. Choose an
appropriate NoSQL model and explain your schema design.
20. Write a sample JSON document structure for a user profile in MongoDB.
{
user_id: 1001,
name: 'Alice',
email: '[email protected]',
order_history: [
{order_id: 1, total: 250.0},
{order_id: 2, total: 150.5}
]
}
22. How do you delete documents from a collection? Support your answer with an example.