One-to-many relationship on a “‘junction’ table”

database-designerdmany-to-many

I have two entity's – Workout and Exercise. These will have a 'many-to-many' (M:N) relationship through the junction table WorkoutExercise. Things start to get complicated when I need to have a 'one-to-many' (1:M) relationship on this table from the table called Sets.

I have provided the entity-relationship diagram below to help illustrate the scenario:

er diagram

Is this poor design? i.e. is it bad for performance? is there a better way?

Best Answer

You can build a unique/primary key in the Workout Exercise table that can be referenced by Sets. That will maintain referential integrity and minimize redundancy, assuming that the surrogate key made up of key values from workout and exercise is unique, and you can create one primary key on sets that has that foreign key referential integrity to the associative (junction) table.