Add a foreign key dept_id
to Branch
referencing Department.dept_id
.
Since dept_id
is unique in Department
, each row in Branch
can thus obviously be linked to exactly one row in Department
, and there can be multiple rows in Branch
containing the same dept_id
.
Thus there will be a one-to-many relationship between the two.
To depict a many-to-many relationship, you need to create a third table that contains:
- A foreign key
dept_id
referencingDepartment.dept_id
and - A foreign key
branch_id
referencingBranch.branch_id