|
Hi everyone, I'm trying to sort out my database before developing my interface any further and have run into a problem. Many to many relationships. I understand the theory but am falling short on putting it to practice for SQL tables. The database is for a university. Do I create a third table i.e module_staff with its own uniqueID i.e module_staffID and include the moduleID and lecturerID as foreign keys? Any quick help with this would be greatly appreciated. Thanks
(comments are locked)
|
|
Your on the right track. Creating another table allowing the joining of modules with lecturers would provide the structure you require. For Example...
Produces the following result... Thanks for your help Jay! However, after analysing my data I realised there was a lot of unnecessary repition. I have 3 tables, one for Reps, one for Lecturers and one for CommitteeMembers - each with a uniqueID, Name and Email fields. Would I not be better consolidating them all into one Users table with a new field for 'Role' in which they can be specified as Rep, Lecturer or Member? If I do this, how to I implement the many-to-many relationship between Lecturers and Modules? Thanks again
Jul 01 '10 at 03:32 PM
Frank 1
Frank, you're on the right track but be careful with adding the "Role" field to the users table. What if one person could serve in more than one role? Could I be a lecturer and a committee member? Having a users table with UserId as the PK and then a RolesRelationships table with the UserId and Role would be more appropriate.
Jul 01 '10 at 08:29 PM
Jay D
(comments are locked)
|

