Module 1 · Lecture 11

Introduction to Non-Relational Databases

Why the relational model cracked at web scale — and the four NoSQL families that replaced it

⏱ 90 minutes 🎯 CLO1 📍 Prerequisites: Lectures 1–10 (relational foundations, SQL) 🔧 Lab: MongoDB Atlas free-tier signup

Contents

  1. Learning Objectives
  2. Session Timeline
  3. Why Relational Databases Hit a Wall
  4. Scaling: Vertical vs Horizontal
  5. CAP Theorem and the ACID/BASE Trade-Off
  6. The Four Families of NoSQL
  7. A Manager's Decision Framework
  8. Five Myths Worth Killing
  9. Hands-On — Create Your Atlas Cluster
  10. Key Takeaways

Learning Objectives

Session Timeline

TimeSegmentActivity
0–8 minRecap & FramingWhere Lectures 1–10 left us; the question this module answers
8–22 minThe Breaking PointThree forces that outgrew the relational model
22–35 minScaling ModelsVertical vs horizontal; why sharding kills joins
35–50 minCAP & ConsistencyCAP theorem, ACID vs BASE, business consequences
50–68 minThe Four FamiliesKey-value, document, column-family, graph — with real systems
68–80 minDecision FrameworkGroup exercise: pick a database for three scenarios
80–88 minAtlas LabCreate a free cluster and a database user
88–90 minWrap-UpAssignment 1 brief and Lecture 12 preview

Section 1: Why Relational Databases Hit a Wall

The relational model is one of the most successful ideas in computing. Edgar Codd published it in 1970; by 1990 it was the undisputed default, and it remains the correct answer for a large share of business systems. Nothing in this module argues that SQL is obsolete. The argument is narrower and more useful: between roughly 2004 and 2010, a specific set of workloads appeared that the relational model served badly, and the industry built new tools for them.

Understanding which workloads those are is the difference between a manager who picks technology on merit and one who picks it on fashion.

Pressure 1 — Data Volume Outgrew the Single Machine

A relational database is designed around one authoritative server. You make it faster by making that server bigger. That strategy works beautifully until your dataset no longer fits on the largest server money can buy — and by the mid-2000s, Google, Amazon, and Facebook had crossed that line.

Scale in context: A well-tuned PostgreSQL instance comfortably handles terabytes. The companies that invented NoSQL were managing petabytes — a thousandfold difference. If your data fits on one big server, the relational model is almost certainly still your best option.

Pressure 2 — Schemas Became a Release Bottleneck

A relational table requires you to declare every column, with its type, before you insert a single row. That rigidity is a feature: it guarantees structure. It becomes a liability when the business changes shape faster than the schema can be migrated.

Consider a product catalogue. A book has an author, an ISBN, and a page count. A refrigerator has a capacity in litres, an energy rating, and a door configuration. A pair of shoes has a size, a colour, and a material. In a relational schema you resolve this with one of three unattractive options:

OptionHow It WorksWhat It Costs
One wide tableEvery attribute of every product type becomes a columnHundreds of mostly-NULL columns; adding a product type means an ALTER TABLE
Table per typeA separate table for books, appliances, footwearQuerying "all products under ₹2,000" means a UNION across dozens of tables
Entity-Attribute-ValueOne generic table of (product, attribute, value) rowsEverything is a string; the database can no longer validate or index meaningfully

A document database sidesteps the dilemma: each product is a document, and each document carries exactly the fields that product needs.

Pressure 3 — The Object-Relational Impedance Mismatch

Application code works with nested objects. A customer has a list of addresses, which each have a postcode. Relational storage cannot nest, so that single conceptual object is shredded across three or four tables on write and reassembled with joins on read.

// What the application wants to work with
{
  name: "Priya Sharma",
  addresses: [
    { type: "home", city: "Delhi",  pin: "110001" },
    { type: "work", city: "Gurgaon", pin: "122002" }
  ]
}

// What a relational schema requires
customers(id, name)
addresses(id, customer_id, type, city, pin)
-- plus a JOIN on every single read

The business translation: impedance mismatch is not an aesthetic complaint. It is paid for in developer hours — writing mapping layers, debugging join logic, and managing migrations. For a product team shipping weekly, that overhead is a direct drag on time-to-market.

Section 2: Scaling — Vertical vs Horizontal

This single distinction explains most of what follows, so it is worth getting precisely right.

⬆️ Vertical Scaling (Scale Up)

Buy a bigger machine: more CPU, more RAM, faster disk. Simple, requires no application change, and keeps all data in one place so joins and transactions stay easy.

Limits: cost rises faster than capacity, there is a hard physical ceiling, and the machine remains a single point of failure.

➡️ Horizontal Scaling (Scale Out)

Add more commodity machines and spread the data across them. Capacity grows almost linearly, cost stays proportional, and losing one node need not take the system down.

Limits: the data is now distributed, which makes joins, transactions, and consistency genuinely hard.

Why Sharding Breaks Joins

Sharding means splitting a dataset across servers by some key — customers A–M on Server 1, N–Z on Server 2. Each server independently handles its slice, which is exactly what makes horizontal scaling work.

Now run a join. SELECT ... FROM orders JOIN customers requires matching every order against every customer. If orders live on Server 1 and the matching customers live on Server 2, the database must ship data across the network mid-query. On a dataset of any size, this is catastrophically slow.

The core insight of NoSQL: rather than making distributed joins fast — which is close to impossible — restructure the data so the join is never needed. Store the order with its customer details embedded. You trade some duplication for the ability to scale horizontally. Every design decision in this module descends from that trade.

Section 3: CAP Theorem and the ACID/BASE Trade-Off

Eric Brewer's CAP theorem (2000) is the most cited and most misquoted idea in distributed data. Stated carefully, it says that a distributed system can guarantee at most two of three properties:

PropertyMeaningIf You Lose It
C — ConsistencyEvery read returns the most recent writeDifferent users may briefly see different answers
A — AvailabilityEvery request receives a responseSome requests fail or time out
P — Partition toleranceThe system keeps working when the network splitsA network fault takes the whole system down

The correction most people need: you do not get to choose whether to have partitions. Networks fail — cables are cut, switches reboot, data centres lose connectivity. Partition tolerance is therefore mandatory for any real distributed system. The genuine choice is what to do during a partition: refuse requests to protect correctness (CP), or answer them and reconcile afterwards (AP).

Reading CAP as a Business Decision

Make it concrete. The network between two data centres fails. Each side can still serve customers, but they cannot talk to each other.

CP — Choose Consistency

Scenario: a bank transfer. The system refuses the transaction rather than risk double-spending the same balance.

Customer sees: "Service temporarily unavailable."

Systems: MongoDB (default), HBase, Redis in cluster mode.

AP — Choose Availability

Scenario: a shopping cart. Accept the item now and reconcile the two versions when the network heals — a slightly stale cart beats a lost sale.

Customer sees: a working site.

Systems: Cassandra, DynamoDB, CouchDB.

ACID vs BASE

These are the two consistency philosophies that follow from the CAP choice.

ACID (traditional)BASE (distributed)
Stands forAtomicity, Consistency, Isolation, DurabilityBasically Available, Soft state, Eventual consistency
PromiseA transaction fully succeeds or fully fails; the data is never in betweenThe system always answers; replicas converge shortly afterwards
Optimises forCorrectnessAvailability and scale
Right forPayments, ledgers, inventory, bookingsFeeds, recommendations, analytics, telemetry, sessions
Wrong forWorkloads needing global write scaleAnything where a stale read costs real money

How the debate actually resolved: the hard either/or of 2010 has softened. MongoDB has supported multi-document ACID transactions since version 4.0 (2018), and most cloud databases now let you choose a consistency level per operation. The modern skill is not picking a camp — it is knowing which guarantee each individual operation requires.

Section 4: The Four Families of NoSQL

"NoSQL" is an unhelpfully broad label — it describes what these systems are not. The useful taxonomy is by data model, and there are four.

1. Key-Value Stores

The simplest possible model: a giant dictionary. You supply a key, you get back a value, and the database does not inspect or interpret that value.

SET  user:8471:session  "{token: 'a9f3...', expires: 1735689600}"
GET  user:8471:session

Strength: extraordinary speed — sub-millisecond lookups, because there is no query planning to do. Weakness: you can only retrieve by key. There is no "find all sessions expiring today" unless you build that index yourself.

Systems: Redis, Amazon DynamoDB, Memcached, etcd. Typical uses: caching, session storage, rate limiting, leaderboards, real-time counters.

You will work with Redis directly in Lectures 17–18, building a live analytics dashboard on top of its bitmap and counter structures.

2. Document Databases

The value is no longer opaque. Each record is a structured document — typically JSON — and the database can query inside it, index nested fields, and enforce optional validation rules.

{
  "_id": "CNR3000142",
  "status": "Completed",
  "vehicle_type": "Go Sedan",
  "route": { "pickup": "Connaught Place", "drop": "Aerocity" },
  "booking_value": 412.50,
  "ratings": { "driver": 4.6, "customer": 4.8 }
}

Strength: the stored shape matches the application's shape, so the impedance mismatch disappears. Related data lives together, which removes most joins. Weakness: data duplicated across documents must be kept consistent by the application.

Systems: MongoDB, Couchbase, Firestore, DocumentDB. Typical uses: product catalogues, user profiles, content management, event and booking records.

This is the family the course focuses on. Lectures 12–16 are built entirely on MongoDB.

3. Column-Family Stores

Data is stored by column rather than by row. Reading one column across a billion rows touches only that column's data on disk instead of dragging every other field along with it.

Strength: enormous write throughput and very fast aggregation over single attributes. Weakness: the data model is rigid and query patterns must be designed up front — you cannot explore ad hoc.

Systems: Apache Cassandra, HBase, ScyllaDB, Google Bigtable. Typical uses: time-series and sensor data, message histories, write-heavy telemetry at scale.

4. Graph Databases

The relationships are the data. Nodes represent entities and edges represent connections, both of which can carry properties.

(Priya)-[:PURCHASED]->(iPhone 15)
(Priya)-[:FOLLOWS]->(Rahul)-[:PURCHASED]->(AirPods)
// "What did people Priya follows buy?" — one hop, not a 5-table self-join

Strength: traversing relationships is constant-time regardless of total dataset size, which is exactly where SQL degrades. Weakness: poor at bulk aggregation; a smaller talent pool.

Systems: Neo4j, Amazon Neptune, ArangoDB, TigerGraph. Typical uses: fraud rings, recommendation engines, social networks, supply-chain and ownership mapping.

Side-by-Side Comparison

FamilyQuery ByBest AtAvoid WhenFlagship
Key-ValueKey onlyRaw speed, cachingYou need to search by valueRedis
DocumentAny fieldFlexible, evolving recordsHeavy multi-entity joinsMongoDB
Column-FamilyPartition + clustering keyMassive write volumeAd-hoc explorationCassandra
GraphTraversalDeep relationshipsBulk aggregationNeo4j
RelationalSQLTransactions, reportingPetabyte horizontal scalePostgreSQL

Section 5: A Manager's Decision Framework

You will rarely write the migration yourself. You will frequently be in the room when the choice is made, and the questions below are the ones that actually settle it.

1

What is the access pattern? Write down the three queries the system will run most often. Choose the database that serves those three well — not the one with the best feature list.

2

How much does a stale read cost? If the answer is "a rupee", you need ACID. If it is "a slightly out-of-date view count", eventual consistency is fine and far cheaper.

3

How fast does the schema change? Monthly changes to the shape of a record favour a document model. A stable schema that has not moved in three years favours relational.

4

What is the realistic data volume in three years? Be honest. Most systems never leave single-server territory, and adopting a distributed database you do not need imports complexity for free.

5

Who will operate it at 3 a.m.? The best database for a team that cannot run it is the wrong database. Managed services such as MongoDB Atlas exist largely to answer this question.

In-Class Exercise — Three Scenarios

In groups, choose a family for each and defend it in one sentence.

#ScenarioDecisive Question
1A ride-hailing firm stores 150,000 bookings a year. Fields differ by product line, and analysts need ad-hoc queries on any attribute.Flexible shape + query any field
2An e-commerce site must show a live "trending products in the last 5 minutes" strip on every page load.Sub-millisecond reads; staleness is harmless
3An insurer wants to find rings of claimants who share addresses, phone numbers, and repair garages.Relationship depth, not volume

Intended answers: (1) Document — this is precisely the Uber dataset you will model from Lecture 12 onward. (2) Key-value — Redis, which you will build in Lecture 17. (3) Graph — a fraud ring is a traversal problem, and SQL self-joins collapse beyond three hops.

Section 6: Five Myths Worth Killing

MythReality
"NoSQL means no SQL"It means "not only SQL". Several NoSQL systems ship SQL-like query languages.
"NoSQL has no schema"The schema moves from the database into the application — and it is still there. MongoDB also offers explicit schema validation.
"NoSQL cannot do transactions"MongoDB has supported multi-document ACID transactions since 4.0 (2018).
"NoSQL is always faster"Only for the access patterns it was designed for. A badly modelled document database is slower than a well-indexed SQL table.
"NoSQL replaces relational"Most large organisations run both. The term for this is polyglot persistence — the right store for each job.

Section 7: Hands-On — Create Your Atlas Cluster

Everything from Lecture 12 onward needs a running MongoDB cluster. The free M0 tier is permanent, requires no credit card, and gives you 512 MB — comfortably more than this course needs.

1

Go to mongodb.com/cloud/atlas/register and sign up. Use your student email — it also unlocks the MongoDB Student Pack.

2

Create a project named BDMA, then Build a Cluster → choose the M0 Free tier.

3

Pick the region closest to you (ap-south-1 / Mumbai for India). Region affects latency, not cost, on the free tier.

4

Security → Database Access → Add New User. Create user bdma_student with a password you record somewhere safe. Grant readWriteAnyDatabase.

5

Security → Network Access → Add IP Address → Allow Access from Anywhere (0.0.0.0/0). This is acceptable for a teaching cluster only — never for production.

6

Connect → Drivers and copy your connection string. It looks like the line below. Save it; Lecture 12 starts here.

mongodb+srv://bdma_student:<password>@cluster0.xxxxx.mongodb.net/

Never commit a connection string to GitHub. It contains a live password. Automated scanners find exposed Atlas credentials within minutes of a public push. Keep it in a local .env file and add that file to .gitignore.

Key Takeaways

✓ What You Should Be Able to Say After This Session

  1. Relational databases did not fail — a new class of workload appeared that they served badly. Volume, schema churn, and impedance mismatch were the three pressures.
  2. Horizontal scaling is the root cause of everything else. Once data is sharded across machines, joins become expensive, which forces a different way of modelling data.
  3. Partition tolerance is not optional. The real CAP decision is how the system behaves during a network split: refuse writes (CP) or accept them and reconcile (AP).
  4. There are four families, not one "NoSQL". Key-value for speed, document for flexibility, column-family for write volume, graph for relationships.
  5. Choose by access pattern, cost of staleness, and operational capability — never by popularity.
  6. Polyglot persistence is normal. Mature organisations run several databases, each doing the job it is best at.

→ Next: Lecture 12 — MongoDB 101 & the Document Model

We move from theory to the keyboard. You will learn how BSON documents are structured, make the central modelling decision of embedding versus referencing, and load your first collection into the Atlas cluster you just created. Bring your connection string.