E
Eric Tubbs
Greetings,
I would like to inquire about how to correctly set up a junction table to
handle a many-to-many relationship. Since Access cant handle this type of
situation, it needs a third table to break the many-to-many into two
one-to-many relationships.
Below are two scenarios and would like your input please.
Example 1: Assigning a primary key for the junction table
tblOrganization
organizationID (pk)
addressID (fk to tblAddress)
tblDepartments
deptID (pk)
deptNmTxt
tblUserDepartment -- Junction Table
userDeptID (pk)
deptID (fk to tblDepartments)
userID (fk to tblUser)
tblUser
userID (pk)
userNmTxt
tblUserRole -- Junction Table
userRoleID (pk)
userID (fk to tblUser)
roleID (fk to tblRole)
tblRoleID
roleID (pk)
roleNmTxt
tblAddress
addressID (pk)
tblEmployee
employeeID (fk)
addressID (fk to tblAddress)
userID (fk to tblUser)
Example 2: Using a multi-primary key for the junction table from the other
two tables
tblUserDepartment -- Junction Table
deptID (fk to tblDepartments)
userID (fk to tblUser)
tblUserRole -- Junction Table
userID (fk to tblUser)
roleID (fk to tblRole)
Which one of these examples (or both) would be acceptable? Is one method
preferred over the other? If so why?
Many TIA's,
Eric
I would like to inquire about how to correctly set up a junction table to
handle a many-to-many relationship. Since Access cant handle this type of
situation, it needs a third table to break the many-to-many into two
one-to-many relationships.
Below are two scenarios and would like your input please.
Example 1: Assigning a primary key for the junction table
tblOrganization
organizationID (pk)
addressID (fk to tblAddress)
tblDepartments
deptID (pk)
deptNmTxt
tblUserDepartment -- Junction Table
userDeptID (pk)
deptID (fk to tblDepartments)
userID (fk to tblUser)
tblUser
userID (pk)
userNmTxt
tblUserRole -- Junction Table
userRoleID (pk)
userID (fk to tblUser)
roleID (fk to tblRole)
tblRoleID
roleID (pk)
roleNmTxt
tblAddress
addressID (pk)
tblEmployee
employeeID (fk)
addressID (fk to tblAddress)
userID (fk to tblUser)
Example 2: Using a multi-primary key for the junction table from the other
two tables
tblUserDepartment -- Junction Table
deptID (fk to tblDepartments)
userID (fk to tblUser)
tblUserRole -- Junction Table
userID (fk to tblUser)
roleID (fk to tblRole)
Which one of these examples (or both) would be acceptable? Is one method
preferred over the other? If so why?
Many TIA's,
Eric