Keys and Relationships
When organizing data across multiple sheets, keys are essential for connecting information.
Primary Key
A primary key is a column that uniquely identifies each row.
Examples:
- Employee ID in an Employees table
- Order Number in an Orders table
- SKU in a Products table
Rules:
- Must be unique (no duplicates)
- Should not change
- Cannot be empty/null
Foreign Key
A foreign key is a column that references the primary key of another table.
Example:
- Dept ID in Employees table → references → Dept ID in Departments table
This creates a relationship between the tables.
Relationship Types
One-to-Many (Most Common)
One department has many employees.- Departments (1) → Employees (Many)
Many-to-Many
One order can have many products, and one product can be in many orders.- Requires an intermediate "junction" table
Why This Matters
Understanding keys helps you:
- Design better spreadsheets
- Avoid data duplication
- Know how to combine data from different sheets
- Transition to databases later