Database Systems · UGC NET: NoSQL
NoSQL Concepts and Data Models
Overview
NoSQL means “Not Only SQL”: a family of non-relational database systems designed for large-scale, schema-flexible, distributed data.
The topic belongs to DBMS extras and tests the CAP theorem, BASE, the four major NoSQL data models, sharding, replication, quorum consistency, and graph traversal.
Before studying it, you should know the relational model, ACID properties, primary/foreign keys, joins, and the idea of a distributed system.
UGC NET asks direct definitions, comparisons, match-list items, statement-based questions, and small numeric quorum or hashing problems.
Key concepts
- CAP theorem (Eric Brewer): a distributed data store cannot simultaneously guarantee Consistency, Availability, and Partition tolerance in the presence of a network partition.
During a partition, a system must choose between CP (reject some requests to stay consistent) and AP (serve requests with possibly stale data).
CA is possible only when there is no partition, effectively a single-node or non-partitioned system. - Consistency in CAP means all nodes see the same value at the same time, formally linearizability or atomic consistency. It is not the “C” of ACID, though related.
- Availability means every request receives a non-error response, but not necessarily the latest value.
- Partition tolerance means the system continues to operate despite arbitrary message loss or delay between nodes.
In an asynchronous network, partitions are unavoidable, so partition tolerance is mandatory for a distributed store. - BASE stands for Basically Available, Soft state, Eventually consistent. It is the relaxed consistency model used by many NoSQL systems.
Soft state means the stored state may change over time without new external input, because replicas are converging. - ACID stands for Atomicity, Consistency, Isolation, Durability. It gives strong transactional guarantees; BASE trades temporary inconsistency for availability and scale.
- Eventual consistency guarantees that if no new updates are made, all replicas eventually converge to the same value. It does not guarantee when, and it does not prevent stale reads meanwhile.
- Tunable consistency: client chooses N replicas per item, W write acknowledgements required, and R read replicas contacted. Strong consistency is possible when W + R > N.
- Sharding or horizontal partitioning splits data across nodes by a shard key. Hash sharding uses ; range sharding keeps ordered ranges. Consistent hashing reduces data movement when nodes join or leave.
- Replication copies the same data item to N nodes for fault tolerance.
Vector clocks detect concurrent updates and conflicts; hinted handoff temporarily stores writes for a down replica; read repair fixes stale replicas during a read. - The four major NoSQL data models:
- Key-value store: unique key maps to an opaque value. Query only by key. Examples: Redis, Riak, DynamoDB. Good for sessions, caches, preferences.
- Document store: key maps to a self-contained document such as JSON/BSON/XML, with nested fields and schema flexibility. Query by document fields. Examples: MongoDB, CouchDB, Couchbase.
Good for catalogs, user profiles, content. - Column-family store (wide-column store): rows with sparse, sorted columns grouped into column families; a column family is roughly a table. Examples: Cassandra, HBase, Bigtable.
Good for time-series, sensor data, large sparse datasets. - Graph store: nodes and edges with properties, using index-free adjacency. Examples: Neo4j, Amazon Neptune. Good for social networks, friend-of-friend, shortest paths, fraud detection.
- Schema-on-read: the application interprets structure while reading, so inconsistent documents can coexist. Schema-on-write enforces the schema when data is written, as in relational DBMS.
- Denormalization by embedding child records inside a parent document reduces the number of reads needed to assemble a result, but it duplicates data and makes updates to embedded children rewrite the parent document.
How it works
- CAP during a partition. A client writes to one node; the network divides the cluster into two groups. A CP system refuses the write or read on the minority side to avoid returning inconsistent data.
An AP system accepts the request on both sides and later reconciles versions. The theorem does not say “pick any two at all times”; without a partition, a well-designed system can provide C and A. - Quorum read and write. The coordinator sends a write to N replicas and waits for W acknowledgements. A read contacts R replicas and returns the version with the highest timestamp or vector clock.
If , every write set and read set must intersect, so at least one read replica has the latest write, assuming enough replicas are live. - Dynamo-style write with hinted handoff.
- Coordinator receives the write and computes the N responsible replicas, often by consistent hashing.
- Coordinator sends the write to all N replicas.
- If a replica is down, another node stores a hint, a temporary copy of the write.
- When the down replica recovers, the hint is delivered and applied. This keeps writes available but may weaken consistency until handoff completes.
- Read repair. During a read, the coordinator contacts R replicas, compares versions, returns the newest value, and writes it back to any stale replica. This repairs inconsistency lazily.
- Graph traversal. In a graph store, each node stores direct pointers to its incident edges and neighbouring nodes. One hop costs on average because no global index lookup is needed.
A k-hop traversal costs per path, proportional to the visited subgraph, while a relational DBMS may need k joins and large intermediate results. - Sharding example. With four shards, . A key whose hash is 10 goes to shard 2, because . The same key always maps to the same shard.
Drawing the diagram…
Formulas
- Quorum consistency rule:
- = number of replicas per data item
- = number of replicas that must acknowledge a write
- = number of replicas contacted for a read
- Strong consistency is possible when the inequality holds; if , a read set and write set can be disjoint, so a stale read is possible.
- Hash sharding:
- = key, = number of shards, = shard index from 0 to .
Worked examples
Example 1 — CAP choice. A distributed store is configured as CP. During a network partition, which guarantee is sacrificed? Step 1: CP keeps Consistency and Partition tolerance.
Step 2: To keep consistency, the system must reject some requests on one side of the partition. Step 3: Therefore Availability is sacrificed. Answer: Availability.
Example 2 — BASE acronym. Geeta uses an online shopping cart that remains available during a network partition but may show a slightly old item count. Expand BASE. Answer: Basically Available, Soft state, Eventually consistent. The cart tolerates temporary inconsistency and converges later.
Example 3 — minimum read quorum. A Dynamo-style store has replicas and . Find the minimum for guaranteed strong consistency. Step 1: Use . Step 2: . Step 3: , so the smallest integer is .
Answer: . With , , which is not greater than 5, so a read set of size 2 and a write set of size 3 can be disjoint.
Example 4 — equality is not enough. A store has , , . Is strong consistency guaranteed by the standard quorum rule? Step 1: Compute . Step 2: Compare with . Step 3: The rule requires , but is false.
Answer: No; a read may miss the latest write because the read set and write set can be disjoint.
Example 5 — sharding count. A key-value store is sharded across 4 nodes by . Keys 10, 14, 18, 22 are inserted. How many distinct shards receive at least one key? Step 1: . Step 2: . Step 3: . Step 4: .
All four keys map to shard 2. Answer: 1 distinct shard.
Comparison
| Feature | ACID | BASE |
|---|---|---|
| Full form | Atomicity, Consistency, Isolation, Durability | Basically Available, Soft state, Eventually consistent |
| Consistency | Strong, immediate | Eventual, temporary inconsistency allowed |
| Availability | May reduce availability to protect consistency | Favours availability |
| Typical use | Banking, billing, strict transactions | Social feeds, catalogs, session stores, large-scale web data |
| NoSQL model | Primary structural unit | Typical query | Examples | Ideal use case |
|---|---|---|---|---|
| Key-value | Key → opaque value | Get/put by key | Redis, Riak, DynamoDB | Cache, session, preferences |
| Document | Key → nested document | Query on document fields | MongoDB, CouchDB | Product catalog, user profile |
| Column-family | Column family / row with sparse columns | Row key, column range | Cassandra, HBase | Time-series, sensor data, sparse tables |
| Graph | Node and edge with properties | Multi-hop traversal, shortest path | Neo4j, Neptune | Social network, recommendation, fraud detection |
| System choice | Behavior during partition | Common examples often cited |
|---|---|---|
| CP | Rejects some requests to keep consistency | HBase, MongoDB |
| AP | Serves possibly stale data to stay available | Cassandra, Riak, DynamoDB |
| Concept | Meaning |
|---|---|
| Vector clock | Version vector per node used to detect concurrent updates and conflicts |
| Hinted handoff | Temporarily stores a write for an unavailable replica and delivers it later |
| Read repair | On read, compares replicas and writes the latest value back to stale replicas |
| Tunable consistency | Client chooses W and R per operation to trade consistency against latency |
| Scaling term | Meaning |
|---|---|
| Horizontal scaling | Add more nodes; sharding and replication; scale-out |
| Vertical scaling | Add CPU, RAM, or disk to one node; scale-up |
| Sharding | Partition different data across nodes |
| Replication | Copy the same data to multiple nodes for fault tolerance |
Revision summary
- CAP: you cannot have C, A, and P together during a partition; partition tolerance is mandatory in a distributed network.
- CP sacrifices availability; AP sacrifices immediate consistency.
- BASE = Basically Available, Soft state, Eventually consistent.
- Strong quorum needs ; is not enough.
- For , minimum ; for , so strong consistency is possible.
- Key-value queries only by key; document stores query by document fields; column-family stores use row key and column ranges; graph stores traverse edges.
- A column family in Cassandra is roughly a table.
- Graph stores are fast for deep multi-hop traversal because of index-free adjacency.
- Schema-on-read means the application interprets structure; it does not mean “no structure”.
- Embedding child records reduces reads but can hurt write performance if the embedded collection is large and frequently updated.
- Sharding splits data; replication copies data; they solve different problems.
- Vector clock detects conflicts; hinted handoff handles down replicas; read repair fixes stale replicas.
Previous-year exam insights
- UGC NET often asks a direct concept: expand BASE, state the three CAP guarantees, or identify the data model for nested catalogs, social networks, or sparse time-series data.
- Statement I/II questions test whether is strict, whether CP sacrifices availability, and whether eventual consistency guarantees convergence only when updates stop.
- Match List-I with List-II expects exact pairs: key-value with key lookup, document with JSON-like document, column-family with sparse wide rows, graph with multi-hop traversal.
- Assertion–Reason questions test the embedding trade-off: embedding reduces reads because a document is fetched as a whole, but updates to embedded children rewrite the parent.
- Numeric questions give and ask for minimum , or give and ask whether strong consistency holds.
Always compute and compare strictly with . - Sharding questions use ; compute each remainder carefully and count distinct shards.
- Order questions on Dynamo-style writes test the sequence: coordinator selects replicas, sends write, stores hint if a replica is down, delivers hint on recovery.
- Common traps: calling CP “partition-tolerant and consistent but available”, treating as sufficient, confusing column family with graph, and assuming a key-value store can query inside an opaque value.
Practice at PARIKSHA
You are ready for the PARIKSHA tests of this sub-topic when you can:
- State the CAP theorem and explain why a CP system sacrifices availability during a partition.
- Expand BASE and compare it with ACID in a table.
- Classify a given use case into key-value, document, column-family, or graph storage with a reason.
- Compute the minimum read quorum for given and , and test whether holds.
- Explain why graph databases traverse multi-hop relationships faster than relational joins.
- Trace a Dynamo-style write with hinted handoff in the correct order.
- Distinguish vector clocks, hinted handoff, and read repair.
- Explain schema-on-read and the read-versus-write trade-off of embedding child documents.
- Compute shard indices using and count distinct shards.
- Identify traps in statement, match-list, assertion-reason, and numeric questions on NoSQL.
Attempt the sub-topic test first, then the subject test.