When modeling many-to-many relationship in ERD we transform it into a separated table in relational model. That table must contains PK of both entities and foreign keys to that PKs.
Let's just say I have
entity1 = id, attributes
entity2 = id, attributes
So, the many-to-many relationship would be
relationship = id1, id2, FK id1=entity.id, FK id2=entity2.id, PK id1,id2
I don't know whether we need to add PK constraint to that table or not. I suppose we need because a table need a PK. Is my way above the correct way to do many-to-many relationship?
Or make it like this?
relationship = id, id1, id2, FK id1=entity.id, FK id2=entity2.id, PK id