I am working on a system where you have users, and you have Fields of Study or 'fos' for short. Each user can have many fos and each fos can have many users. So we are dealing with a many to many scenario. Here is the rub, each user can have many fos they act as an instructor for, and can also have many fos they act as a student for. How is this relationship defined? Would you have two junction tables one like user_instructor_fos and one like user_student_fos?
Mysql – Multiple junction tables
MySQLrelational-theory
Related Question
- Mysql – Bit column vs multiple join tables
- MySQL Many-to-Many – How to Insert Values in Junction Table
- MySQL Database Design – Are Junction Tables Good Practice?
- MySQL Table Schema Design – Relationship with Junction or User Table
- Mysql – Online Learning: Different User Roles Different Fields
- Relational Theory – Unique Relationship Attribute for Every Pair of Entities
Best Answer
You can simply add an "is_student" bit column to the relation "UserToFOS", and create a unique key on user_id, fos_id and is_student.