- LPU MCA Semester 1
- CAP570
- Unit 6
CAP570 · Unit 6: Advanced databases
NoSQL databases
15 practice questions · in the ETE syllabus
Key points
- Four types: key-value, document, column-family, graph
- Horizontal scaling and flexible schema
- BASE favours availability and eventual consistency
- CAP: not all of C, A and P at once
NoSQL ("not only SQL") databases are non-relational systems designed for large scale and flexible data. They usually scale horizontally by adding commodity servers, allow a flexible schema, and often relax ACID in favour of availability.
| Type | Stores | Examples |
|---|---|---|
| Key-value | Values looked up by key | Redis |
| Document | JSON-like documents | MongoDB |
| Column-family | Wide rows grouped by column family | Cassandra, HBase |
| Graph | Nodes and relationships | Neo4j |
In a document store, documents in one collection can have different fields, so a query may test whether a field exists. A graph database answers relationship questions such as friends of friends by following edges. Many NoSQL systems follow BASE (Basically Available, Soft state, Eventual consistency) instead of ACID: a replica can briefly return an old value until the update reaches it.
The CAP theorem says a distributed store cannot guarantee Consistency, Availability and Partition tolerance all at once, so during a network partition it must choose consistency or availability.
Exam trap: NoSQL does not mean there is no SQL-like querying, and eventual consistency is a trade-off, not a defect.
Try two questions
MongoDB stores JSON-like records. Which type of NoSQL database is it?
- Key-value store
- Graph database
- Column-family store
- Document database
Show the answer
D. MongoDB stores JSON-like documents.
Why not A: Redis is a typical key-value store.
Why not B: Neo4j is a typical graph database.
Why not C: Cassandra is a typical column-family store.
Which property is a typical advantage of NoSQL databases for web-scale applications?
- A rigid schema, so every record must have the same columns
- A guarantee of ACID transactions across all nodes at all times
- A flexible schema, so new fields can be added without altering a table definition
- A requirement to normalise all data to third normal form
Show the answer
C. Schema flexibility makes it easy to evolve data models.
Why not A: Rigid schemas are typical of relational databases.
Why not B: Many NoSQL systems relax ACID guarantees.
Why not D: Normalisation is a relational design technique.