Do I need a composite primary key in a junction table?
You should use the combination of EntityId and TagId as composite primary key, here is why:


This will enforce uniqueness, that you will have to do even if you add a surrogate key.
These columns are what you will base most if not all of your queries on this table, so they should be indexed anyway
Adding a surrogate key will not have any benefit from the performance perspective.


btw, I don't know about MySql, but in Sql Server, a primary key is not necessarily the clustered index. It is set as the clustered index by default, but you can change the clustered index to any other index if you need.