This article is about the one-to-many relationship in a relational model.
For example, in a geography schema having tables Region, State, and City:
The key point is that each city exists in exactly one state, but a state may have many cities, hence the term many-to-one
One-to-many relationships are used to represent:
In cube modeling (dimensional schema), this relationships:
This is a binary relationship with 1:n mapping in which:
In relational databases, these many-to-one relationships are enforced and materialized with foreign key/primary key constraint.
This is why a One-to-many is also known as a primary Key-Foreign Key Relationship.
In a child relationship, we may want to give the child table a primary key composed of the parent ID column.
For instance:
Parent Id Column | Child Id Column |
---|---|
1 | 1 |
1 | 2 |
2 | 1 |
2 | 2 |
… | … |
Advantage:
Disadvantage:
Conclusion: uses a single ID value to identify a single object
An orphan instance is created while loading data into an entity if you insert an instance that does not have an existing parent instance.
For example, you load an article into a fact table but this article code is not present in the article dimension. This record is an orphan record.
When loading orphan instance, you can specify the integrity policy used: