A one-to-many relationship occurs when one row in a parent table can have multiple related rows in a child table, such as one customer having many orders.
Most transactional databases use one-to-many relationships, and they directly affect JOIN results and aggregations.
Join each customer to all orders placed by that customer.
SELECT
c.CustomerName,
o.OrderID,
o.OrderAmount
FROM Customers c
INNER JOIN Orders o
ON c.CustomerID = o.CustomerID;
Used in sales, banking, HR, inventory, customer, and transaction systems.
- One parent can have many child records.
- JOIN results may contain repeated parent values.
- Aggregation is often used for summaries.
- Foreign keys commonly represent the relationship.
- Cardinality should be considered before calculating totals.
What is a one-to-many relationship?
It occurs when one row in a parent table can be associated with multiple rows in a child table.
What happens when a one-to-many relationship is JOINed?
The parent row can appear once for each matching child record.