Models, abstraction, and databases
By the end of this module you will be able to:
- Explain Codd's relational model and the guarantees ACID properties provide
- Apply the CAP theorem to choose a database for a given consistency-availability trade-off
- Identify the correct NoSQL model (document, key-value, column-family, graph) for a data pattern
Database choice triaged by workload across four shapes
Database choice is a workload triage, not a vendor argument, across OLTP, analytics, search, and graph.
Database choice is a workload triage, not a vendor argument: OLTP for transactions, analytics columnar for aggregation, search index for free-text, graph for relationship queries. Choosing by team familiarity instead of workload hits the boundary as soon as scale arrives.
Lakehouse: open-table format adds transactions to data lake
Lakehouse adds open-table transactions to data-lake storage so promotion gates and time-travel become possible.
Lakehouse is the architecture that gives lake-scale storage warehouse-grade transactions: open table formats (Iceberg, Delta) plus the medallion promotion gates. Without the open table format you have a data lake; with it, you have a lakehouse. Databricks coined the term; Apache Iceberg made the storage layer vendor-neutral.

Real-world architecture decision · 2012
Twitter FlockDB: storing wide social graph adjacency lists at scale
In 2010, Twitter's engineering team described FlockDB, a distributed database for storing social graph edges such as who follows whom. The problem was not deep graph theory. It was operational scale: very large adjacency lists, high read and write rates, paging through millions of edges, and set operations that had to stay fast under social network traffic.
A relational model can represent the same relationship with a followers table, but the access pattern matters. If the product frequently asks for all followees of one account, all followers of one account, or set differences between two adjacency lists, the storage design should make those reads local and predictable rather than forcing wide joins through a general-purpose schema.
FlockDB's lesson is more precise than "use a graph database for graphs". It shows that the correct database abstraction starts with the query pattern. Deep multi-hop traversal, fraud ring discovery, and knowledge graph reasoning need graph traversal engines. Wide social adjacency lists need fast edge storage, set arithmetic, and horizontal scaling.
Twitter had 500 million users, each with hundreds of followers and followees. The follower graph did not fit the relational model efficiently. What makes graph databases the right abstraction for social network relationships?
Database choice starts with the shape of truth: what must be stored, what must be queried, and what must never be half-written.
22.1 The relational model and ACID
Edgar Codd published "A Relational Model of Data for Large Shared Data Banks" in 1970. His insight was that data should be represented as relations with tuples and attributes, and that users should specify what data they wanted rather than navigating machine storage paths. SQL emerged from IBM research in the 1970s, became an ANSI standard in 1986, and became an ISO standard in 1987. The current ISO/IEC 9075 family is SQL:2023.
ACID properties define the guarantees a relational database provides for transactions. Atomicity means a transaction either completes fully or not at all: there is no partial update state. Consistency means the database moves from one valid state to another valid state, enforcing all defined constraints. Isolation means concurrent transactions do not see each other's in-progress changes (at the configured isolation level). Durability means committed transactions survive system crashes: the data is written to persistent storage before the commit is acknowledged.
These guarantees matter because real business operations involve multiple related changes. A bank transfer must debit one account and credit another atomically. If the system crashes after the debit but before the credit, the atomicity guarantee means the debit is rolled back. Without ACID, financial systems, inventory management, and booking systems would produce incorrect results during failures or concurrent access.
SQL query optimisation uses an execution plan: a tree of operations (scans, joins, sorts, aggregations) that the query planner selects to minimise cost. Indexes on frequently queried columns allow range scans instead of full table scans. EXPLAIN ANALYSE in PostgreSQL reveals the actual execution plan and row counts, which is the first tool to reach for when a query is slow.
ACID explains correctness inside a transaction; distributed systems force the same correctness question across machines that can lose contact with each other.
“It provides a means of describing data with its natural structure only.”
E.F. Codd, 'A Relational Model of Data for Large Shared Data Banks', Communications of the ACM (1970) - Section 1
Codd separated the logical representation of data from the physical storage path. That separation is why SQL can ask for a result without telling the database which index, join order, or disk page to use.
22.2 The CAP theorem and distributed databases
Eric Brewer's CAP conjecture (2000), formally proved by Seth Gilbert and Nancy Lynch in 2002, is often reduced too far. The useful form is this: when a network partition occurs, a distributed data system must choose between consistency and availability for the affected operation. Consistency means a read receives the most recent write or an error. Availability means every request receives a non-error response, without guaranteeing it is the newest value. Partition tolerance means the system continues to have defined behaviour when messages between nodes are delayed or dropped.
In practice, network partitions are not optional in a distributed system. The real trade-off is between consistency and availability during the partition. A CP design refuses reads or writes it cannot prove are consistent. An AP design serves potentially stale reads or accepts writes that will be reconciled later. Outside a partition, many systems can provide both useful availability and strong consistency for normal operations.
The right choice depends on the application. A banking ledger requires CP: serving a stale balance could allow overdrafts. A product catalogue or social media feed tolerates AP: a slightly stale product count or a delayed post count is acceptable. Most modern distributed databases (Cassandra, DynamoDB, CockroachDB, MongoDB) implement tunable consistency, allowing the application to choose the consistency level per query.
The next decision is not SQL versus NoSQL as a slogan; it is whether the access pattern is relational, document-shaped, key-based, append-heavy, or relationship-heavy.
Common misconception
“NoSQL databases do not support ACID transactions.”
This was true of early NoSQL systems but is no longer accurate. MongoDB has supported multi-document ACID transactions since version 4.0 (2018). Amazon DynamoDB supports transactions across multiple items. CockroachDB and Google Spanner are distributed SQL databases offering full ACID guarantees at global scale. The modern choice is not between SQL (ACID) and NoSQL (no ACID) but between different data models and consistency trade-offs, many of which can now be implemented with transactional guarantees.
22.3 NoSQL data models and when to use them
Four primary NoSQL data models address different access patterns that the relational model handles poorly or inefficiently.
- Document stores (MongoDB, Firestore) store JSON or BSON documents. Ideal for data with variable schema (product catalogues with different attributes per category), hierarchical data that would require many joins (a blog post with embedded comments), or rapid development where schema evolves frequently.
- Key-value stores (Redis, DynamoDB) retrieve values by a primary key with microsecond latency. Ideal for caching, session storage, leaderboards, and rate limiting where the access pattern is always get/set by a known key.
- Column-family stores (Apache Cassandra, HBase) store data in columns grouped into column families, optimised for wide-row writes and time-series data. Ideal for IoT sensor ingestion, event logs, and metrics where data is appended chronologically and queried by time range.
- Graph databases (Neo4j, Amazon Neptune) store nodes and edges with arbitrary properties, optimised for multi-hop traversal. Ideal for social networks, recommendation engines, fraud detection (unusual transaction graph patterns), and knowledge graphs where relationship traversal is the primary operation.
The prerequisite skill is abstraction discipline. A conceptual model names the business things and relationships. A logical model turns those into entities, attributes, constraints, and identifiers. A physical model commits to indexes, partitions, denormalisation, clustering keys, and storage engines. Senior leaders need this chain because platform choices create lock-in and operational risk. Engineers need it because a database can only be excellent for the queries it was designed to answer.
A payment processing system must ensure that when a customer pays for an order, the payment record and the order status update either both succeed or neither does. The system handles 10,000 transactions per second across three database nodes. Which ACID property is most critical here, and why?
An IoT platform ingests 50,000 temperature sensor readings per second, each with a sensor ID, timestamp, and temperature value. Readings are always appended (never updated) and queried by sensor ID and time range. Which database model is best suited to this workload?
A distributed database cluster experiences a network partition: nodes A and B can communicate with each other but not with node C. Under the CAP theorem, the system must choose between consistency and availability. A financial ledger application is using this database. Which choice is correct and why?
Core checks before moving on
- Codd's relational model separates logical data structure from physical storage path; SQL grew from that idea and is now maintained as ISO/IEC 9075.
- ACID protects transaction correctness. Atomicity prevents half-finished business events, isolation controls concurrent visibility, and durability survives crashes after commit.
- CAP is a partition-time trade-off: during a network partition, a distributed system must choose whether to preserve consistency or serve availability for the affected operation.
- NoSQL is not one design. Document, key-value, column-family, and graph databases optimise for different access patterns.
- Model choice should move from conceptual to logical to physical design before technology preference enters the conversation.
Standards and sources cited in this module
E.F. Codd, 'A Relational Model of Data for Large Shared Data Banks', ACM (1970)
The founding paper of relational database theory. Introduced the concepts of relations, tuples, and the precursor to SQL.
Formal proof of the CAP theorem. The authoritative reference for the consistency/availability trade-off in distributed systems.
Amazon DynamoDB team, 'Dynamo: Amazon's Highly Available Key-value Store', SOSP (2007)
Describes the eventual consistency model, consistent hashing, and vector clocks used by DynamoDB. Foundational to understanding AP-oriented distributed databases.
Current international SQL standard family for relational database language conformance.
Apache Cassandra documentation: data modelling
Stable Apache Cassandra documentation for query-driven modelling, partition design, and column-family storage.
Twitter Engineering: Introducing FlockDB
Primary engineering context for FlockDB as a social graph edge store optimised for wide adjacency lists and set operations.
Module 22 of 26 · Practice & Strategy