How a data warehouse stores customers and their purchases in linked tables, using one shopper's rows and the tags that join them.
A data warehouse is a giant, tidy store of information that helps people answer questions. Instead of shelves of boxes, it keeps everything in tables: grids of rows and columns, a bit like a spreadsheet.
Big warehouses can hold billions of rows, far more than any spreadsheet.
An entity is a thing we care about: a customer, a product, a shop. Each row of an entity table holds one entity. Here Ana slides out of the Customers table, wearing her own ID tag, #7.
The ID tag is called a key. No two customers share the same key.
Attributes describe an entity. Ana's name, the city she lives in and her membership level are her attributes. Each one is a column in her row.
Events are things an entity does, or things that happen to it, each at a moment in time. Ana bought apples, then a kite, then a book. Attributes and events are both characteristics of Ana.
Attributes change now and then. Events keep piling up.
Because events keep coming, each one is written as a new row in an events table. Every event row carries Ana's tag, #7, instead of a copy of everything about her. Three events point to one entity.
Designers call this many-to-one: many events, one customer.
To answer a question, the warehouse joins tables. It follows the tags on a sale to the matching rows in the Customers and Products tables, then sets the pieces side by side. Join the first sale to see it.
A join only matches tags while answering. Nothing is moved or copied for good.
With events in the middle and entities all around, the tables form a star. Following the tags lets the warehouse answer big questions, like how many apples were bought in Lyon.
Designers call this layout a star schema.