Which one of these three techniques you would prefer and why for many-to-many situations (using MySQL)?
Three fields in the link table, id, linked_id1, linked_id2. (InnoDB)
id = primary_key
linked_id1 (linked to the host table with foreign_key)
linked_id2 (linked to the host table with foreign_key)
Two fields in the link table, linked_id1 and linked_id2. (InnoDB)
primary_key = (linked1, linked2)
linked_id1 (linked to the host table with foreign_key)
linked_id2 (linked to the host table with foreign_key)
Two fields in the link table, linked_id1 and linked_id2. (MyISAM)
primary key = (linked_id1, linked_id2)
unique index = (linked_id2, linked_id1)
And then join data in code.
so when joing to the table, it’ll work efficiently no matter which column the join was on. PK is one index and another reverse index should be created.