question

Frank 1 avatar image
Frank 1 asked

More trouble with many to many relationships

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.
I have 3 tables: a modules table and a users table.

Modules Table
[moduleID] [moduleName] [Rep_ID]

Users Table
[User_ID] [First_Name] [Surname] [Email_Address] [Role]

Roles Table
[Role]

Role can be 'Lecturer', 'Rep', or 'Committee_Member' and this is where my trouble comes in.
A lecturer can have multiple modules and a module can have multiple lecturers.

How do I set up tables to implement this many-to-many relationship based on a particular role? My development has come to a complete halt until I solve this.

Please note: I am using Visual Studio 2010 to interact with and manipulate my tables because of an unspecified error with SSMS.

Any quick help with this would be greatly appreciated. Thanks!

Also, as a side question in case anyone is feeling extra helpful: the [Rep_ID] in modules table. Could I simply use the User_ID as a foreign key?

Thanks again!!

sql-server-2005databasecreatenormalizationdatabase-diagrams
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Scot Hauder avatar image
Scot Hauder answered

Module Table

[Module_ID], [Module_Name]

User Table

[User_ID],[First_Name],[Last_Name],[Email_Address]

UserModule Table

[User_ID],[Module_ID]

Role Table

[Role_ID],[Role_Name]

UserRole Table

[User_ID],[Role_ID]

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.