Brock
09/13/2021, 2:08 AMassigned_depts
is one or many departments?jason-lynx
09/13/2021, 2:32 AMfiles
table and folders
table, and there's a folder_id
foreign key in the files
table.
to do that in M-N cases, the solution tends to be creating an intermediate table (or composite table) e.g. user_departments
that sits between the 2 tables. the simplest version just has 3 cols:
id, user_id, dept_id
, with user_id
and dept_id
being foreign keys to users
and departments
respectively. this breaks down the overall rs from M-N into two different 1-M relationships, giving you the advantages mentioned aboveBrock
09/13/2021, 2:34 AMuser_departments
table for all of the rows that have the user_id
of the corresponding user?jason-lynx
09/13/2021, 2:35 AMjason-lynx
09/13/2021, 2:36 AMjason-lynx
09/13/2021, 2:37 AMBrock
09/13/2021, 2:38 AM