# 1.4 The Depot (The Table)

When you have enough shipping containers (Pages) stacked together, you have a
**Depot**. In Postgres, we call this a **Table** (or a Relation, if you want to sound like a professor).
## The Architectural Permit (DDL)
Before the Lazy Elephant can stack a single container, he must first approve the **Architectural Permit**. In the world of databases, we call this **DDL** (Data Definition Language).
Think of DDL as the rigid, uncompromising blueprint for a new building in the depot. It defines exactly how many floors the building has, what kind of luggage is allowed inside, and most importantly, it gives the building a name so the elephant doesn't get confused.
Here is the first permit we sign for the Elephant Cafe:
```sql
-- Signing the Permit for the Species table
CREATE TABLE species (
id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
name TEXT UNIQUE NOT NULL,
diet_type diet_category NOT NULL
);
```
Once this permit is signed (executed), the elephant clears a space on the disk and prepares to receive the first shipping containers!
## Stacking the Containers (Segments)
A table isn't a complex, mystical entity. It is fundamentally just a very long, very wobbly line of 8KB shipping containers. However, the OS file system gets grumpy if files become too large. To appease the host OS, Postgres imposes a strict **1GB limit** on any single physical file.
If your depot grows beyond 1 Gigabyte, the elephant simply grabs a hacksaw, chops the building off, and starts a new **Segment** file directly next door (e.g., `16385`, `16385.1`, `16385.2`). To the querying user, it looks like a single infinite depot, but on disk, it is a neatly organized campus of 1GB buildings.
## The Side Rooms (Forks)
A depot isn't just a single hallway of luggage. Real tables have "side rooms," branching off the main building, called **Forks**.
The main hallway where the data lives is the **Main Fork**. But the elephant also maintains specialized blueprints in the side rooms:
- **The Free Space Map (`_fsm`)**: A quick sketch showing exactly which shipping containers have empty space, so the elephant doesn't have to check every single box when cramming in a new suitcase.
- **The Visibility Map (`_vm`)**: A secret list indicating which containers hold ONLY fully alive, completely visible suitcases. If everyone agrees the suitcases are safe to look at, the elephant can entirely skip checking the Bureaucratic Bird stamps!
## The Manager (The Elephant)
The Lazy Elephant doesn't like to wander aimlessly through the depot. To find a specific suitcase, the elephant usually starts at the very first container and walks past every single one until it finds what it’s looking for. This is called a **Sequential Scan**.
Imagine a depot that is six miles long. The elephant begins at the entrance, yawning and checking his pocket-watch. By the time he reaches the end, he’s missed three tea parties and his trunk is dragging on the floor!
## Cleanliness (The Vacuum)
Because the elephant refuses to throw anything away, the depot floor quickly becomes cluttered with "Old" suitcases that have been crossed out with the frantic **[[Chapter 1/1.0 - The Building Blocks of Storage|Red Sharpie]]**.
To prevent the depot from becoming infinite, a tiny robotic vacuum cleaner (the **Autovacuum**) wanders around. The vacuum's job is to find containers full of dead suitcases, throw them into the incinerator, and make sure the "Free Space" in those containers is ready for the next batch of luggage.
Without the vacuum, the depot would eventually consume the entire universe, which would be very inconvenient for anyone trying to have a nice sit-down.
---
| ← Previous | ↑ Table of Contents | Next → |
| :--- | :---: | ---: |
| [[Chapter 1/1.3 - The Shipping Container (The Page)\|1.3 The Shipping Container (The Page)]] | [[Learn You a Postgres for Great Good\|Home]] | [[Chapter 1/1.5 - The Sharpie Ledger (MVCC)\|1.5 The Sharpie Ledger (MVCC)]] |