0% found this document useful (0 votes)
3 views4 pages

NoSQL Exam Answer Key

The document is an answer key for a NoSQL database exam, covering topics such as the definition of NoSQL, types of NoSQL databases, BASE properties, advantages, data modeling differences, sharding, and the CAP theorem. It includes specific questions and answers related to MongoDB, including how to create collections, databases, and document structures. Additionally, it discusses performance optimization techniques and tools for database modeling.

Uploaded by

umucyowacuaxelle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

NoSQL Exam Answer Key

The document is an answer key for a NoSQL database exam, covering topics such as the definition of NoSQL, types of NoSQL databases, BASE properties, advantages, data modeling differences, sharding, and the CAP theorem. It includes specific questions and answers related to MongoDB, including how to create collections, databases, and document structures. Additionally, it discusses performance optimization techniques and tools for database modeling.

Uploaded by

umucyowacuaxelle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Answer Key – NoSQL Database Exam (SWDND501)

Section A: Answer All Questions (55 Marks)


1. What is NoSQL, and how does it differ from relational databases?

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.

2. Name and briefly describe four types of NoSQL databases.

1. Document Stores – Store data in JSON-like documents (e.g., MongoDB).


2. Key-Value Stores – Use a simple key-value pair model (e.g., Redis).
3. Column-Family Stores – Store data in columns rather than rows (e.g., Cassandra).
4. Graph Databases – Use nodes and edges to represent data and relationships (e.g., Neo4j).

3. Explain BASE properties in NoSQL databases.

BASE stands for:


- Basically Available: The system guarantees availability.
- Soft State: The system state may change over time.
- Eventually Consistent: The system will become consistent over time.

4. What are the key advantages of using a NoSQL database?

- Flexible schema design.


- High scalability.
- Fast read/write performance.
- Handles unstructured data well.

5. How does data modeling in NoSQL differ from relational databases?

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.

6. Describe sharding and why it is important in NoSQL databases.

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.

7. What do you understand by Compass environment?


MongoDB Compass is a graphical user interface that allows users to visualize, explore, and
manipulate their MongoDB data easily without using the command line.

8. How do you create a collection in MongoDB?

In MongoDB, you can create a collection using: `db.createCollection('collectionName')`.


Collections can also be created automatically when a document is inserted.

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.

- MongoDB: Document-oriented database for web apps.


- Redis: Key-value store for caching and session management.

11. How does indexing work in NoSQL databases?

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?

- Sharding: Splits data across multiple machines.


- Replication: Copies data across multiple machines for redundancy and fault tolerance.

13. What is a conceptual data model?

It is a high-level representation of organizational data, focusing on entities and their


relationships. It does not include physical details.

14. Why is schema validation important in MongoDB?

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

16. How do you create a new database in MongoDB?


Use: `use newDatabaseName`. MongoDB will create the database when a document is
inserted.

17. How do you rename a collection in MongoDB?

Use: `db.oldCollectionName.renameCollection('newCollectionName')`

Section B: Choose 3 out of 5 Questions (10 Marks Each)


18. Describe the steps to install and configure a NoSQL database (e.g., MongoDB,
Cassandra). Mention key system requirements and configurations.

1. Download MongoDB from the official site.


2. Install using the setup wizard.
3. Configure environment variables (optional).
4. Start MongoDB server using `mongod`.
5. Use MongoDB Compass or `mongo` shell to connect.
System requirements: At least 4GB RAM, 64-bit OS, disk space for data.

19. Suppose you are designing a NoSQL database for an e-commerce platform. Choose an
appropriate NoSQL model and explain your schema design.

Model: Document Store (MongoDB).


Collection: products
{
_id: ObjectId,
name: 'Product Name',
price: 199.99,
category: 'Electronics',
reviews: [{user: 'John', rating: 5, comment: 'Great'}]
}

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}
]
}

21. Provide different NoSQL Models.


- Key-Value Store
- Document Store
- Column-Family Store
- Graph Database
Each serves a different purpose based on use case.

22. How do you delete documents from a collection? Support your answer with an example.

Use: `db.collection.deleteOne({field: 'value'})` or `db.collection.deleteMany({})`


Example: `db.users.deleteOne({name: 'Alice'})`

Section C: Choose 1 out of 3 Questions (15 Marks Each)


23. How do you define a document structure in MongoDB? Support your answer with an
example.

A document in MongoDB is a JSON-like object. Example:


{
_id: ObjectId('...'),
name: 'John Doe',
email: '[email protected]',
age: 30,
interests: ['coding', 'reading']
}

24. Explain three performance optimization techniques in NoSQL databases.

- Indexing: Improves query speed.


- Denormalization: Reduces joins and improves read performance.
- Sharding: Distributes data across servers to balance load and increase performance.

You might also like