Abstractions, Interfaces, and the Narrow Waist
Interfaces as liberation
An interface is a contract that liberates application writers from low-level details. It represents an abstraction of the resources and services used by applications. In an ideal world, implementations can change without requiring changes to applications.
In practice, this ideal is often undermined by:
- Performance concerns: a naive abstraction may perform poorly on a particular implementation, forcing the application writer to become aware of what lies beneath.
- Mission creep: the interface specification grows over time, adding features that tie applications to specific implementations.
- Specification change: the interface itself is revised, breaking existing applications.
Standard interfaces are everywhere
The narrow waist pattern recurs in many engineered systems:
| System | Interface | What sits above | What sits below |
|---|---|---|---|
| National electricity grid | 230 V, 50 Hz socket | Appliances | Power stations, renewables, interconnectors |
| Landline telephone | RJ11 jack, dial tone | Telephones, fax machines, modems | Exchanges, trunks, fibre, microwave links |
| Money | Currency units, prices | Buyers, sellers, contracts | Central banks, commercial banks, ledgers |
| TCP/IP | Sockets, ports | Applications | Ethernet, Wi-Fi, 4G, fibre |
In each case, the interface decouples the consumers of a service from the providers. New providers can enter below the interface; new consumers can enter above it.
The DBMS logical arrangement
Applications interact only with the DBMS. The DBMS uses the operating system’s file system, which in turn uses device drivers to access physical storage. Some high-performance DBMSs bypass the file system and manage raw storage devices directly.
Storage interface primitives
Primary storage (RAM) provides a simple word-level interface:
write(address, word)
read(address)
Secondary storage (disk/SSD) provides a block-level interface:
write(blkaddress, block)
read(blkaddress) → option(block)
trim(blkaddress)
sync()
readreturns an option: the block might not exist (unlike RAM, where every address always contains something).trimtells the device that a block is no longer needed (used by SSDs for garbage collection).syncflushes buffered writes to persistent media.
Storage configurations
| Configuration | Where data lives | Persistence |
|---|---|---|
| In-core | Primary memory (RAM) | Ephemeral — lost on process exit or power loss |
| Serialised to filesystem | Files managed by the OS | Persistent across restarts |
| Direct device access | Raw secondary storage, bypassing the file system | Persistent, with full DBMS control over layout |
Most general-purpose DBMSs use the serialised-to-filesystem configuration. In-core databases (e.g., Redis) are used where latency is critical and the dataset fits in RAM.
Summary
- An interface is an abstraction that decouples consumers from providers.
- The narrow waist model appears in many engineered systems, not just databases.
- The DBMS sits between user applications and the file system/device drivers.
- Secondary storage differs from primary storage in providing block-level access with optional read results.