Link a primary key to a foreign key in a relational database system
Linking Tables with Primary Keys and Foreign Keys
How relational tables connect in a real schema
The primary advantage of a relational database is that you can store data in multiple tables (each table focused on one subject), and then link those tables when you need combined information.
The link is created by copying the primary key of a parent table into a related table where it becomes a foreign key. That one design move enables accurate joins, prevents “orphan” rows, and supports reliable reporting at scale.
What it means to “link” two tables
Two tables are linked when they share a matching key value:
Parent table: owns the primary key (unique identifier).
Child table: stores the parent key value as a foreign key (reference).
In the example used throughout this lesson, a supplier can provide many products. That is a common one-to-many relationship:
SUPPLIERS (1) → PRODUCTS (many)
Primary key and foreign key at a glance
The diagram below shows the two tables and how the linking column appears in both places.
Read it from top to bottom: SuppID uniquely identifies a supplier in Suppliers, and the same value is stored in Products
to indicate which supplier provides each product.
You cannot insert a Products.SuppID value that does not exist in Suppliers.SuppID.
You cannot delete a supplier row that is still referenced, unless you deliberately choose a delete rule (RESTRICT, CASCADE, SET NULL) that matches the business requirement.
Naming foreign keys when column names collide
In real schemas, column name collisions happen (especially with short names like ID).
If the same column name appears in multiple tables, use a consistent naming convention so the meaning is obvious:
Include the parent subject in the child foreign key name (example: supplier_id).
Use a standard suffix like _id for identifiers.
Avoid special characters (do not use dotted names like SUPPLIERS.SuppID as a column name).
The goal is that developers can read the schema and infer relationships without guessing.
When you link tables correctly, query results become information: data organized to answer a question.
In the next lesson, you will begin using SQL to create tables and write queries that join them.
[1]foreign key: A field (or combination of fields) in a child table that references a primary key (or UNIQUE key) in a parent table.
[2]data integrity: The correctness and consistency of data, including enforcement of valid relationships (referential integrity) between tables.