To create a good database, I have to know the relationship between tables.
It is clear, the database I talking about is relationship database.
There are three types of table relationships.
- One-to-one relationships
- One-to-many relationships
- Many-to-many relationships
In a one-to-one relationship, a key will appear only once in a related table. It is the most simply relation.
In a one-to-many relationship, keys from one table will appear multiple times in a related table.
The exapmle is a connection between department and employees. One department has many employees. One employee can only be in one department.
It is a very common type of relationship.
The many-to-many relationship often causes problems in practical examples of normalized databases, so much so that it is common to simply break many-to-many relationships into a series of one-to-many relationships.
I call it an intermediate table, which is one-to-many table. It connect the many-to-many tables.