Beginner bootcamp · Module 3
Storage 101: where data actually lives
8 min reading · Sources
Outcome: Choose memory, durable records and object storage from access and recovery needs rather than a database brand.
More
Page details
Published date · Last edited:
Prerequisites: How servers scale: from one instance to a fleet
Hypothetical scenario: Northwind stores uploaded product images, cart items and cached catalog results in the same place. A restart loses some data, while oversized records make ordinary product queries expensive. The issue is the mismatch between each data item’s lifetime and access pattern.
Words to recognize
RAM
Definition: Volatile random-access working memory. Related topic
SSD
Definition: Solid-state storage that retains data without power, subject to device and write guarantees. Related topic
Object storage
Definition: A service storing byte objects under keys with metadata. Related topic
Primary key
Definition: A database key uniquely identifying a row. Related topic
Transaction
Definition: A group of operations governed by a commit or rollback boundary. Related topic
Replica
Definition: A copy of data maintained through a replication protocol. Related topic
A kitchen needs several storage surfaces
A cook uses a counter for immediate work, a refrigerator for ingredients and a storeroom for bulk supplies. Their value comes from different access patterns, not from declaring one universally best. RAM is volatile working memory. SSD storage can retain bytes without power, but durability still depends on acknowledgments, buffering and recovery. A write sitting only in a volatile buffer can disappear before it reaches durable media.
Block storage exposes addressable blocks. File storage exposes files and directory operations. Object storage exposes objects under keys through a service API. These interfaces give applications different responsibilities; they are not interchangeable names for the same database.
Separate records from large byte objects
A relational database organizes records into tables. A primary key identifies a row; a foreign key expresses a reference to another row. A transaction groups operations under a commit or rollback boundary. PostgreSQL’s physical storage documentation describes how logical records are represented in files and pages; a table is not one giant in-memory spreadsheet.
A document store groups flexible structured records, a key-value interface retrieves values by key, and a graph interface emphasizes relationships. These categories do not alone establish consistency or availability. A read replica copies data for additional read capacity; a shard owns a subset of the dataset. Adding replicas does not partition all writes automatically.
Derive payload size before choosing hardware
Assume 100,000 product records each have 2,000 bytes of logical metadata. Their payload is 100,000 × 2,000 = 200,000,000 bytes, or 200 decimal megabytes. Assume one 5,000,000-byte image per product. Image payload is 100,000 × 5,000,000 = 500,000,000,000 bytes, or 500 decimal gigabytes.
The images are 500,000,000,000 ÷ 200,000,000 = 2,500 times larger than the metadata payload. A reasonable starting design stores image keys in records and the image bytes in object storage. These numbers exclude indexes, replicas, versions, encoding and backups; add each explicitly instead of calling logical payload the total storage bill.
Choose the recovery promise
Hypothetical scenario: a cache holds the only copy of an accepted cart update. Eviction removes it, and the application cannot rebuild the cart. This was an accidental authority decision. Persist accepted state in a chosen durable record, then treat the cache as a disposable acceleration layer.
A second mistake is reading a lagging replica immediately after a write and interpreting an older value as a failed write. Route read-after-write checks to an authority or require a suitable freshness contract. Use replication for the promised read and recovery behavior; use sharding when partitioned ownership is actually needed. Neither replaces backups that can recover from accidental deletion replicated to every copy.
Know which changes must be one transaction
Atomicity concerns the defined operation unit completing together or not taking effect. Isolation describes what concurrent transactions may observe and how they interfere. Durability is the preservation promise after acknowledgment under the chosen failure model. Consistency in ACID refers to application and database invariants, while the word also appears in distributed read-observation models. Always say which meaning is intended. A foreign key may protect a reference; it cannot decide an unstated business rule.
For a transfer, subtracting from one balance and adding to another should have a defined atomic boundary, plus a rule preventing negative available funds if required. When records cross independent databases, ordinary local commit does not automatically span them. Coordinated commit or a workflow with reservations and compensation may be necessary. A beginner should first identify the invariant and its owner; selecting a NoSQL or SQL label does not answer where that invariant is enforced.
Explain why an index changes the work
Without a suitable index, a query may need to examine many rows to find matches. An index maintains another access structure so a lookup can narrow the candidates. That structure takes space and must be maintained when relevant data changes. A book index is a useful analogy, but a database also needs to handle concurrent updates, page storage and recovery. More indexes can help reads while adding write work.
Normalization keeps facts in deliberately separated relations to reduce certain update anomalies. Denormalization duplicates or combines facts for selected reads, which creates an obligation to update or rebuild those copies. A cached search document is often a projection rather than the authority for accepting a purchase. State that distinction so a stale product description is not mistaken for an authoritative inventory check. Choose an index or projection from the actual query, its freshness requirement and the write cost you can afford. Start with the simplest model meeting these requirements, then change it when measured work or operational needs justify the complexity.
Check your decisions
Is a read replica the same as a shard?
No. A replica holds a copy of data. A shard owns a partition. Their effects on reads, writes and failure recovery differ.
Does the 500 GB image calculation equal the storage bill?
No. It is logical payload only. Versions, redundancy, indexes, backups and service charges require separate assumptions.
If a cache is evicted, should an accepted order disappear?
No. The authoritative order must survive cache loss. A cache-only acceptance path silently changes the durability promise.
Go deeper
- Database Physical Storage — PostgreSQL Global Development Group · Primary document. Connects logical records to files, pages and physical layout. Verified 2026-10-26.
Decision log
Decision: assign an authority and recovery rule to each data class.
Limit: a storage category does not prove a particular durability or consistency guarantee.
Next decision: express reliability and speed as measurable service criteria.