DSM
40 XP
20 minsBeginner40 XP

What Makes a Dataset?

You can now read a table — but 'that column' and 'the one that links the two files' won't survive a real team conversation. Data people share a precise vocabulary: features, records, keys, granularity. Learn these five words and you can describe any dataset exactly, join two of them correctly, and read pandas documentation without translating in your head. By the end you'll name every part of a dataset like a professional.

What you'll learn

  • Name a dataset's records and features using standard vocabulary
  • Identify the key (unique identifier) of a dataset
  • State the granularity — what one record represents
  • Explain why a key must be unique and non-missing
  • Connect these terms to rows and columns you'll see in pandas

What

A dataset is a structured collection of data with named parts: records (rows), features (columns), a key that uniquely identifies each record, data types on each feature, and a granularity — the level of detail one record captures.

Why

Vague words cause real bugs. If you can't say which column is the key, you'll join two tables wrongly and silently duplicate rows. If you can't state the granularity, you'll mix daily and monthly data. Precise vocabulary is precise thinking.

Where it's used

Every database schema, every pandas DataFrame, every data dictionary a team writes. Joining tables, grouping data, and designing a database all depend on these terms.

Where this runs in production

AmazonKeys link orders to customers

An orders table and a customers table are connected by customer_id — a key. Getting that key right is how Amazon attaches every purchase to the right account without mixing people up.

InstagramGranularity decides the story

A table at one-row-per-post answers different questions than one at one-row-per-account. Instagram's analysts pick the granularity that matches the metric they're reporting.

TeslaFeatures are the sensor readings

Each vehicle log record carries dozens of features — speed, battery temperature, GPS. Naming and typing those features correctly is what makes fleet-wide analysis possible.

Theory

The core ideas, in plain language.

You already know a row is an observation and a column is a variable. Data teams have interchangeable names for these, and you'll meet all of them. A row is also called a record or an instance. A column is also called a feature, a field, or an attribute. Same grid, richer vocabulary.
Key Concept
The five parts of a dataset

Record — one row (also: instance). Feature — one column (also: field, attribute). Value — one cell. Key — the feature (or features) that uniquely identifies each record. Granularity — the level of detail one record represents. Master these five and you can describe any dataset precisely.

The key is the most important new idea. A key is a feature whose value is unique for every record and never missing — like customer_id or order_id. It's the dataset's fingerprint: give me a key value and I can find exactly one record, with no ambiguity.
Analogy: A key is a passport number

Two people can share the name 'Maria Garcia', the same birth city, even the same birthday. But no two people share a passport number — it's issued to be unique. A key does the same job for records: names and other features can collide, but the key always points to exactly one row. That's why databases join on keys, not on names.

order_id   customer_id   item        price
A-1001     C-77          Headphones  59.99
A-1002     C-77          Cable       9.99
# key = order_id (unique per row). customer_id repeats — the same
# customer placed two orders — so it is NOT the key of this table.

order_id is unique on every row, so it's the key. customer_id appears twice because one customer made two orders — it's a real feature, but not this table's key. It is, however, the link (a foreign key) to a separate customers table.

Granularity is the level of detail a record captures — the answer to 'what is one row?' from the last lesson, now given a name. 'One row per order' is finer granularity than 'one row per customer'. You can always summarise fine data up to a coarser level, but you can never invent detail that a coarse dataset didn't record.
Watch out
Don't use a name or email as a key without thinking

Names repeat and change; even emails get reused or shared. Using them as a key leads to two different people being merged or one person being split. Prefer a purpose-made ID (customer_id, order_id). If you must key on something real-world, confirm it's genuinely unique and never missing first.

Visual Learning

See the concept, then explore it.

Two Tables, One Key

Click each part to see its role. Notice how customer_id links the two tables — that shared key is the heart of relational data.

Worked Examples

Watch it built up, one line at a time.

Very EasySpot the key

A table has features employee_id, name, department, with one row per employee.

Step 1 of 1

A key must be unique on every row. employee_id is (E-01, E-02...); name and department repeat across people. So employee_id is the key.

Code
01employee_id name department
02E-01 Priya Sales
03E-02 Dave Sales
Output
Key = employee_id (unique and non-missing).
Practice Coding

Your turn — write the code.

Your task

Below is a small dataset with its column names. Describe it using the standard vocabulary by filling in the blanks: which feature is the key, and what the granularity is. Then a quick check counts the records for you. Run it when done.

Expected output
Key: visit_id
Granularity: one gym visit
Records: 3

Write your solution in the editor on the right, then hit Run.

Exercises

Prove it. Reach 80% to complete the lesson.

Mastery Gate0% / 80% required
Easy0/2 solved

What is a 'feature' in a dataset?

What two properties must a key have?

Medium0/3 solved

A table lists one row per order, with columns order_id and customer_id. customer_id appears on several rows. What is customer_id in this table?

ScenarioA colleague wants to use customer full name as the key to merge two datasets, because 'everyone's name is different'.

How should you respond?

Check whether a column can be a key by testing if all its values are unique. Given a list of id values, print 'unique' if there are no duplicates and 'not unique' otherwise. Hint: compare len(ids) with len(set(ids)).

Detects duplicates:Compares list length to the set of distinct values.
Output:Prints 'not unique' because 'A-2' appears twice.
Hard0/1 solved
ScenarioYou have a table with one row per (product, warehouse) combination showing stock levels. Neither product_id nor warehouse_id is unique on its own.

What identifies each record?

Complete 80% more exercises to unlock.
Interview Prep

How this shows up in real interviews.

What is a key in a dataset, and why does it matter?

Show model answer

A key is the feature, or combination of features, that uniquely identifies each record — its value is unique on every row and never missing, like order_id or customer_id. It matters because it's how you reliably find, deduplicate, and join data. When I merge two datasets, I join on a shared key so each record links to exactly the right match; without a proper key, joins duplicate or drop rows silently. A good key is stable and purpose-made rather than something like a name that can repeat or change.

What is the granularity of a dataset, and why do you check it before combining two datasets?

Show model answer

Granularity is the level of detail one record represents — for example one row per order versus one row per customer. I check it before combining datasets because mismatched granularity is a classic source of wrong numbers. If I join a per-order table to a per-customer table without accounting for the difference, I either fan out the customer rows across every order or accidentally sum a customer's total multiple times. The rule I keep in mind is that you can always aggregate finer data up to a coarser level — roll orders up to a per-customer total — but you can never recover detail a coarse dataset never captured. So I confirm the granularity of each side first and decide whether to aggregate one of them before the join.

Explain the difference between a primary key and a foreign key, and give an example of when a single column is both.

Show model answer

A primary key is the column that uniquely identifies each record within its own table — customer_id in a customers table, where every customer appears exactly once. A foreign key is a column in another table that references a primary key elsewhere, creating a link — customer_id in an orders table, where it repeats because one customer places many orders. The same column name plays both roles depending on the table: customer_id is the primary key in customers and a foreign key in orders. A column can even be both in a single table in more advanced designs — for instance a self-referencing employees table where manager_id is a foreign key pointing back to employee_id, the table's own primary key. The practical point is that primary keys enforce uniqueness and foreign keys enforce valid links, and joins are built on matching a foreign key to its primary key.

Common Mistakes to Avoid

1) Calling a repeating column the key — a key must be unique on every row. 2) Using names or emails as keys; they collide and change, so prefer a purpose-made ID. 3) Forgetting composite keys when no single column is unique (e.g. product + warehouse). 4) Joining two datasets without checking their granularity, which silently duplicates or drops rows.

Ask the AI Tutor

Try these prompts in the AI Tutor panel: • 'Give me a table and quiz me on which column is the key.' • 'ELI5: what is a composite key?' • 'Show me two datasets and ask which key I'd join them on.' • 'Explain granularity with a fresh example and a trap to avoid.' • 'Interview mode: ask me to explain primary vs. foreign keys.'

Glossary

Dataset — a structured collection of records and features. Record — one row (also: instance). Feature — one column (also: field, attribute). Key — the feature(s) uniquely identifying each record. Primary key — the key within a table. Foreign key — a feature that references another table's primary key. Composite key — a key made of two or more features together. Granularity — the level of detail one record represents. Data dictionary — a document describing each feature's meaning and type.

Recommended Resources

• Reference: 'Primary key' and 'Foreign key' overviews on any beginner SQL tutorial (W3Schools or Mode's SQL tutorial). • Practice: take any two spreadsheets you own and identify a key that could link them. • Concept: read a short 'what is a data dictionary?' explainer to see how teams document features formally. • Next in DSM: you can now describe a dataset precisely — next you'll learn to judge whether you can trust it, starting with data quality.

Recap

✓ A dataset is made of records (rows) and features (columns), holding values in each cell. ✓ A key uniquely identifies each record — it's unique on every row and never missing. ✓ A primary key identifies records in its own table; a foreign key links to another table's key. ✓ When no single feature is unique, a combination can form a composite key. ✓ Granularity is the level of detail one record represents, and it must match before you combine datasets. Next up: Data Quality Basics. You can now name every part of a dataset — but naming it doesn't mean you can trust it. Next you'll learn to spot the missing values, duplicates, and inconsistencies that make data unreliable.

scratchpad — preview this lesson's challenge anytime
describe_the_dataset.pyPython
Ready
Output

Run your code to see the output here.