,

A Database and a File

This post is about where one order lives and where the pile of past orders goes. It’s the third in the Data Architecture series. From post 1 you need order 1042, the support email, the photo of the coat, and the same order written as JSON. From post 2 you need one idea: the app records the order now, and a later question reads many past orders.

Northwind Outfitters is a fictional shop, and so is every number about it here.

TL;DR

  • Order 1042 stays in PostgreSQL. The JSON export, the coat photo, and the support email sit as objects in one bucket.
  • One shelf finds a row by a key. The other holds bytes plus a description of them. A photo is not a table.
  • Decide by what the data holds and how it is found. S3 bills for storage, requests, and transfer. This post doesn’t price the database.

One order, two shelves

What you get: where Northwind keeps order 1042, where it keeps the history, and the names for both places.

Post 2 gave one order two jobs. This post asks where the bytes sit. The order the app just took and the pile of past orders don’t want the same kind of shelf.

Start with the order. Customer 18 bought a wool coat for £120 on 28 September. In Northwind’s order system, that order is one row in a table called orders, in a database called PostgreSQL. Two more tables, customers and order_items, sit beside it. “Current” here only means the row the app stores and reads. It isn’t the name of a history feature.

Now the history. Post 1 mentioned the nightly export, which is the same order written out as JSON, with a name on every field. An export is a copy of data written to a file. The row stays where it is. Northwind also saves the photo of the coat and the support email. All three go into one bucket, a container that holds files. That’s three objects.

Keeping the history as files is Northwind’s choice. It isn’t a claim about what other shops do.

Each shelf has a name. A database keeps rows and columns. PostgreSQL is the example in this series. Object storage keeps files in buckets. Amazon S3 is the example.

A database can copy rows out to a file. Amazon RDS for PostgreSQL, a hosted version of the database, can send that export straight into an S3 bucket. That’s one real path from the first shelf to the second.

Order 1042 as a row in the database, beside a bucket holding three objects: the JSON export, the coat photo, and the support email
Figure: Order 1042 stays as a row in the database, and the JSON export, the coat photo, and the support email sit as three objects in one bucket.

Take away: the current order is a row in a database. The history, the photo, and the email are objects in a bucket.

How a row is found, and what an object is

What you get: how the database finds order 1042, what an object is, and how a copy travels from one shelf to the other.

This section is the mechanism behind the two shelves. You can skip it, and “Which shelf” still works.

How the database finds order 1042

A table is rows and columns. In PostgreSQL the number of columns is fixed. Each column has a name, and they come in a set order. The number of rows grows and shrinks with what’s stored. In orders, each order is a row. The order number, the customer, and the date are columns.

A primary key is a column, or group of columns, that identifies a row uniquely. The values must be unique and not null, which means every cell must have a value. A table can have at most one primary key. PostgreSQL does not require every table to have one. Northwind’s key is the order number. When you add a primary key, PostgreSQL builds an index on those columns.

An index is a separate structure that helps the database find rows without reading all of them. Think of the index at the back of a book. Without one, a request for order 1042 makes the database read every row. With one, it can walk a few levels of a search tree and land close to the row. PostgreSQL’s default index type is the B-tree, which handles a lookup on one exact value, like “order number equals 1042.”

The PostgreSQL docs say an index can be read relatively quickly, compared with reading the whole book. Here, “quickly” only means quicker than reading every row. It holds only when the planner, the part of PostgreSQL that chooses how to run a query, picks the index. It does that when it expects the index to beat a full scan. This post gives no timing for either route.

The index has a cost. PostgreSQL has to keep it in step with the table, so it adds work whenever data changes.

What an object is

An object, in S3’s terms, is a file plus any metadata that describes it. Metadata is a set of name-value pairs, such as a label and its value. A bucket is a container for objects.

Each object has a key, the name you use to get it back. The key is unique within the bucket. The object itself can be any run of bytes. If the bucket keeps versions, the key plus a version ID identifies one version. That’s all you need about versions here.

Keys can start with a shared string, called a prefix. Prefixes can organize keys in a way similar to folders. They aren’t folders. When this post says “folder,” it means a shared prefix. Northwind’s JSON export might be exports/order-1042.json. The prefix is exports/, and the rest is the file name. That key is an illustration.

How a copy gets out

PostgreSQL’s COPY command copies a table, or the result of a query, to a file. Its formats are text, csv, and binary. Post 1’s JSON file is this series’ way to show an order as named fields. It isn’t a COPY format.

RDS for PostgreSQL goes a step further. Once an extension called aws_s3 is installed, it can write query results straight to files in an S3 bucket. The file path is a prefix plus a file name. The sources don’t say what happens to the source rows.

One sentence on table formats

A table format is the set of rules that lets a folder of order files act like one table. For Northwind, that would mean its order files could be read as one orders.

The Apache Iceberg spec describes its format as one for managing “a large, slow-changing collection of files” as a table. The format keeps track of individual data files, not of a folder listing. The spec also says the files it manages can live in an object store like S3.

That’s all this post says about table formats. Post 5 covers Parquet and how files are laid out. Post 6 covers how the tracking works, and it’s where Delta Lake and Hudi wait.

Take away: a database finds a row by its key, through an index the planner chooses. An object store finds an object by its key in a bucket.

A photo does not become a table

What you get: why the coat photo can sit in a bucket, or even in a database, and still not be a table.

The coat photo in the bucket is an object: a key, some bytes, and metadata.

A database can hold a photo too. PostgreSQL has a column type called bytea. It stores a binary string, a run of raw bytes, as a column value. A photo can sit inside a row that way. But that value is one cell in a row. It isn’t a table.

S3 describes tabular data as data in columns and rows, like a database table. It describes an object as a file plus metadata. S3 also has a separate bucket type for tables stored in the Iceberg format. Northwind’s bucket isn’t that. It’s a general purpose bucket of objects, which is what you get when you upload photos, videos, or documents.

The point is narrow. The Iceberg spec defines a data file as “a file that contains rows of a table.” The photo has no rows of orders in it, so it isn’t one, and it isn’t a table wherever it’s stored.

Take away: a photo is bytes with a description. Storing it in a bucket, or in a bytea column, doesn’t make it a table.

Architecture Reality Check: The Cloud Bill

>

The bill for a bucket isn’t one number, and storage is only one part of it. S3 list prices have no minimum charge. Cost components include storage, requests and data retrieval, and data transfer.

>

Here are list prices in US dollars for S3 Standard in US East (N. Virginia). They come from the AWS price list published 28 September 2026, and I checked them on 12 Oct 2026. They aren’t a Northwind invoice.

>

– Storage: $0.023 per GB per month for the first 50 TB, $0.022 per GB for the next 450 TB, and $0.021 per GB beyond 500 TB. – Saving, copying, or listing objects (PUT, COPY, POST, and LIST requests): $0.005 per 1,000 requests. – GET and all other requests, as AWS’s price list describes them: $0.004 per 10,000 requests. GET is the request used to read an object. – DELETE and CANCEL requests: free. DELETE is the request that removes an object. CANCEL is its own request.

>

Data transfer is also billed. This post gives no rate for it. It gives no database price either, so it can’t say which shelf costs less.

>

When someone quotes you a price per GB, ask what else is on the bill: requests and data retrieval, and data transfer.

Which shelf

What you get: two questions you can ask of any piece of data, Northwind’s answers, and a table to keep beside you.

No source gives a rule for when a record should move from a database to files, so here are two questions. You can skip the mechanism section for these.

First: what does the thing hold? Is it rows and columns, or is it bytes plus a description of them?

Second: how will you look for it? Will you want one row by its key, or a pile read together?

Here are Northwind’s answers. Order 1042 is one row, and the app looks it up by order number. The shop keeps it in PostgreSQL. The JSON export, the coat photo, and the support email are objects, and they sit in one bucket. That’s the shop’s choice.

A database (PostgreSQL)Files in object storage (Amazon S3)
How one thing is foundOne row, by its primary key. When the planner uses the index, that beats reading every row.One object, by its key in the bucket.
What it holdsRows and columns. A bytea column can hold a photo’s bytes as one value. That value isn’t a table.Bytes plus metadata. The coat photo is an object, not a table.
What you pay forNot priced in this post.Storage, requests, and transfer. The US East (N. Virginia) S3 Standard list price is $0.023 per GB for the first 50 TB per month. Check date: 12 Oct 2026.

Table: A database and files in object storage. No speed number is given; the sources here don’t give one for these shelves.

My view: ask what the data holds before you ask which product to buy. Rows you’ll look up by key fit a database. A photo, an email, or a pile of exported files fits a bucket.

Take away: ask what the thing holds and how you’ll look for it. Then pick the shelf.

Close

Order 1042 stays in PostgreSQL. The JSON export, the coat photo, and the support email sit in one bucket. A photo is not a table.

The posts ahead pick up the threads I’ve left open. Post 4 looks at how data architecture has changed over time. Post 5 compares the JSON export with a file laid out in columns. Post 6 explains how the tracking behind a table format works.

3 Questions for Your Architecture Team

  1. For each thing you keep, do you find one row by a key, or do you read a pile together?
  2. Which of those things are rows and columns, and which are bytes, a photo included, that you’ve been treating as a table?
  3. On the object-storage bill, where do storage, requests, and transfer each show up, and what does the database shelf cost on its own?

Terms in this post

TermMeaning in this post
Primary keyA column, or group of columns, that identifies one row. Unique and not null. Northwind’s is the order number.
IndexA structure the planner can use to find matching rows without reading every row. Here it’s a B-tree, used to look up the order number.
PlannerThe part of PostgreSQL that uses the index when it expects that to beat a scan of the whole table.
Object storageA bucket of objects. Amazon S3 is the example.
ObjectA file plus metadata, retrieved by a key that’s unique in the bucket. The value is any run of bytes.
BucketA container for objects. This post’s bucket is a general purpose bucket.
PrefixA string at the start of an object key. It can organize keys in a way similar to folders. It isn’t a folder.
byteaA PostgreSQL column type for raw bytes. A photo can sit there. That value isn’t a table.
Table formatThe rules that manage a collection of files as a table and track individual data files instead of directories.

Architectural field notes, straight to your inbox.

Essays when they publish. The Daily Radar stays on the site.

Leave a Reply