A one-to-many relationship occurs when one row in a parent table can be associated with multiple rows in a child table.
One-to-many relationships are extremely common and are a major reason JOIN queries can return multiple rows for a single parent record.
One customer can place many orders.
SELECT
c.CustomerName,
o.OrderID,
o.OrderAmount
FROM Customers c
INNER JOIN Orders o
ON c.CustomerID = o.CustomerID;
Common in customer-order, department-employee, account-transaction, and product-sales systems.
- One parent can have many child records.
- JOIN results can contain multiple rows per parent.
- Foreign keys commonly represent the child side.
- Aggregations may be required after the JOIN.
- Always understand relationship cardinality.
What is a one-to-many relationship?
It is a relationship where one record in a parent table can relate to multiple records in a child table.
Give a common one-to-many example.
One customer having multiple orders is a common one-to-many relationship.