Course
In this tutorial, I will explain what the one-to-many relationship is, how to implement it in database design, and the best practices to follow to keep your databases scalable and efficient.
If you are starting as a database engineer, I recommend taking our Introduction to Relational Databases in SQL and Database Design courses to learn how to create relationships when defining your database schema.
What Is a One-to-Many Relationship?
A one-to-many relationship (1:N) describes the scenario where one record in a table can be linked to multiple records in another table. In plain terms, it means one thing exists once but can be connected to many related things.
For example, a single customer can place many orders, but each order belongs to only one customer.
You’ll often see one-to-many relationships described using these terminologies:
- Parent table: A table that contains the “one” record
- Child table: A table that contains the “many” records
From our example, the customer record will be in the parent table, and the orders table will be in the child table.
Understanding Cardinality in One-to-Many Relationships
Cardinality describes how many records can be connected between two tables. It answers questions like:
- How many orders can a customer have?
- Can a customer exist without any orders?
One-to-many relationships are asymmetric, meaning the rules are different on each table. On the parent table, a single record can relate to many records, while on the child table, each record can relate to only one record.
Cardinality also includes minimum and maximum limits, where:
- Minimum cardinality: The least number of related records allowed.
- Maximum cardinality: The most related records allowed.
For example, a customer may have zero or many orders, but an order must belong to exactly one customer.
These rules influence table design by indicating whether certain fields can be empty, and how strictly the database enforces relationships.
Visualizing One-to-Many Relationships with ER Diagrams
In database design, an Entity-Relationship (ER) diagram is a visual way to show tables (entities), how they are connected (relationships), and how many records can be linked (cardinality).
ER Diagram notation
Most ER diagrams use specific symbols at the ends of the lines connecting your tables to tell you exactly what the relationship is. Below are the commonly used visual ideas for:
- Entities: Drawn as rectangles to represent tables like
CustomersorOrders. - Relationships: Shown as lines connecting entities to indicate how entities relate to each other
- Cardinality symbols: The number
1or a single line represents the one, while∞,*, or a crow’s foot, represents the many relationship.
Simple ER Diagram example
The example below shows the relationship between the Customers and the Orders table. The one-to-many relationship shows that one customer can have many orders, but each order belongs to one customer. The CustomerID appears in the Orders table to link it back to the Customers table.

Common Examples of One-to-Many Relationships
The following are examples of one-to-many relationship scenarios you may come across:
- Author → Books: One author can write multiple books, but each book has a single author (in a simple design).
- Department → Employees: One department can have many employees, but each employee belongs to one department
- Category → Products: One category can contain many products, but each product is assigned to one category.
Implementing a One-to-Many Relationship in a Relational Database
One-to-many relationships are implemented using primary keys and foreign keys. In this section, I will show you how these constraints help enforce data integrity in databases.
Primary and foreign keys
The primary key is a column that uniquely identifies each row in a table, while the foreign key is a field or set of fields in one table that refers to the primary key in another table.
In a one-to-many relationship, the “one” side has a primary key, and the “many” table stores that key as a foreign key. The foreign key then creates the link between the two tables and ensures that each record on the “many” side points to a valid record on the “one” side.
Basic SQL example
Let’s look at how you would build a one-to-many relationship in SQL using the example below.
You will create the Customers table where CustomerID uniquely identifies each customer. This is the parent table.
-- Create Customers table with CustomerID as primary key
CREATE TABLE Customers (
CustomerID INT PRIMARY KEY,
CustomerName VARCHAR(100)
);
Now create the Orders table where the CustomerID is a foreign key. In this table, each order references exactly one customer and is the child table.
-- Create Orders table with CustomerID as a foreign key
CREATE TABLE Orders (
OrderID INT PRIMARY KEY,
OrderDate DATE,
CustomerID INT,
FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID)
);
One-to-Many vs. Many-to-Many Relationships
Understanding the difference between one-to-many and many-to-many relationships is important for correct database design. The table below summarizes these differences:
|
Aspect |
One-to-Many Relationship |
Many-to-Many Relationship |
|
Definition |
One record in Table A can relate to many records in Table B |
Records in Table A can relate to many records in Table B, and vice versa |
|
Relationship Direction |
One → Many (one-way) |
Many ↔ Many (two-way) |
|
Rule on Table B |
Each record in Table B relates to only one record in Table A |
Each record in Table B can relate to many records in Table A |
|
Common Examples |
Customer → OrdersDepartment → Employees |
Students ↔ CoursesProducts ↔ Orders |
|
Real-World Meaning |
A customer can place many orders, but each order belongs to one customer |
A student can enroll in many courses, and each course can have many students |
|
Implementation |
Single foreign key on the many side |
Requires a join (junction) table |
|
Foreign Key Location |
Stored in the “many” table |
Stored in the join table (two foreign keys) |
It’s important to note that relational databases cannot directly store many-to-many relationships using a single foreign key. Instead, they use a join table (also called a junction or bridge table).
For example, you can safely relate records in the Students table to the Courses table using the Enrollments table as the join table. The join table breaks the many-to-many relationship into two one-to-many relationships, hence stores foreign keys to both tables. This design helps in database normalization, maintaining efficiency.
I recommend taking our Joining Data in SQL course to learn the different types of joins in SQL and how to work with different related tables in the database.
Common Mistakes with One-to-Many Relationships
The following are some of the common issues you may encounter in one-to-many relationships, and how to troubleshoot:
- Putting the foreign key in the wrong table: When you store the foreign key in the “one” table instead of the “many” table, you end up storing multiple values in one column or repeating columns, which breaks normalization and makes querying difficult. To solve this issue, always place the foreign key on the many side of the relationship.
- Confusing One-to-Many with Many-to-Many: If you model a relationship as one-to-many when both sides can actually have multiple related records, it can lead to missing data, duplicated rows, or rigid designs that can’t grow with requirements. To fix this problem, always confirm if a child record can have multiple records, and if yes, then use a join table.
- Allowing orphaned records unintentionally: Letting child records exist without a valid parent record can create inconsistent data, such as orders with no customer or employees without a department. To solve this, use foreign key constraints like ON DELETE CASCADE, so the database enforces valid relationships automatically.
Best Practices for Designing One-to-Many Relationships
I recommend the following best practices as a guide to help you design efficient and scalable one-to-many relationships:
-
Use clear and consistent naming: Name primary keys predictably, such as
CustomerIDandOrderID. Clear naming makes relationships obvious without diagrams and is helpful when matching foreign key names to the referenced primary key. -
Enforce foreign key constraints: Use foreign keys to let the database protect data integrity and prevent invalid or orphaned records, especially as your data grows.
-
Think about deletion behavior early: You can decide what should happen to child records when a parent is deleted to avoid accidental data loss or broken references. For example,
CASCADEensures all the child records are deleted when the parent record is deleted. -
Keep designs simple: Always avoid unnecessary tables or complex relationships, and keep your design to the model that you need now, not hypothetical future cases. Remember that simple designs are easier to maintain, explain, and extend.
Conclusion
A one-to-many relationship describes how a single record in one table can be associated with multiple records in another, while each of those related records belongs to only one parent. This pattern is foundational in relational database design because it keeps data organized and prevents unnecessary duplication.
I recommend our Associate Data Engineer in SQL career track to learn to design databases in SQL to process, store, and organize data efficiently. Also, if you are looking to advance your database management skills for big data, our Introduction to Data Modeling in Snowflake course will help you with dimensional modeling.
FAQs
How is a one-to-many relationship different from many-to-many?
In one-to-many, only one side can have multiple related records; in many-to-many, both sides can, which requires a join table.
Which table holds the foreign key in a one-to-many relationship?
The foreign key is stored in the table on the “many” side of the relationship.
Can a one-to-many relationship exist without a foreign key?
Conceptually, yes, but in practice, foreign keys are strongly recommended to enforce data integrity and prevent invalid records.
How do I know if my data model should be one-to-many or many-to-many?
Ask whether both sides can have multiple related records. If yes, it’s many-to-many; if not, it’s one-to-many.
What is cardinality in relationships?
Cardinality describes the numerical relationship between the two tables. In a 1:N relationship, the cardinality is one on the parent side and many on the child side.
