Is it a bad practice to use primary key in junction tables?

To my brain they are of equal complexity - you are doing one more join while I’m doing a subquery. But certainly yours is much better formatted and the aliases also make it more readable.

I will do it in my mind - I’m getting rid of the two conditions in the second join :smile:

This was a very quick act of designing a database and I just let Mysql Workbench leave the default table names :smiley:

I wouldn’t say it is very inconvenient - it can be a slight inconvenience having to use a composite key but as r937 showed getting rid of the composite FK can have its drawbacks, too.

Correct - but I think a good ORM would be able to make out all the relations based on the composite keys without having to replace them with AI primary keys - in other words, this would be transparent to the user (developer).

Yes, but I fear that the deeper we go down the chain of relationships the farther the translated objects would be in appearance and behaviour from the database and we would end up with two very distinct worlds. That is of course the goal of ORM but I’m not sure if this would make things easier for the developer. I’ve never really queried such complex data structures with ORM but I suppose the task of getting all user’s labels with colours would be quite an undertaking without resorting to SQL.