I've read that when designing a simple many to many table, the best way to deal with primary key is to set it over both two columns. That's how I did that in table which assigns users to workgroups. But now, I've more complicated table, which describes, what permission have a user or a workgroup when accessing shared FSO (file system object = folder or file). I've used solution from this answer so I'm using two columns for specifyin' FSO and two for specifying allowed user or workgroup. My table looks like this:
id INT (primary key)
shared_file INT (foreign key)
shared_folder INT (foreign key)
allowed_user INT (foreign key)
allowed_workgroup INT (foreign key)
permission TINYINT
CONSTRAINT CHECK (shared_file IS NOT NULL OR shared_folder IS NOT NULL)
CONSTRAINT CHECK (allowed_user IS NOT NULL OR allowed_workgroup IS NOT NULL)
But now I come up with the idea that I don't actually need an extra column for id, basically this table is also many to many. But I don't know if I should set primary key over all 4 columns or how to do it to preserve consistency.