You've learned to query single tables, but real databases have multiple, related tables. How do we connect a customer to their orders, or link products to categories?
The answer is special columns called "keys" that keep data organized and connected. Think of keys as unique ID numbers that help tables communicate efficiently.
Engagement Message
What problems might arise if we can't uniquely identify database rows?
A primary key is a column (or combination of columns) that uniquely identifies each row in a table. Think of it like a fingerprint - no two rows can have the same primary key value.
Like your social security number, no two rows can have the same primary key value.
Engagement Message
Can you think of what might be a good primary key for a "customers" table?
Here's a simple customers table example:
CUSTOMERS
Notice how customer_id is unique for each person? That's our primary key!
