I want to know which will be the best.
I am having a table say A having col1(is a foreign key fk1),col2(is also a foreign keyfk2).
Can I use PK as (col1,col2) or a newly generated PK.
The queries will have fk1 in criteria and fk2 in joins.
Kindly suggest me a best one.
P.S I am using mysql
If this is a many-to-many link table, just use
(col1, col2)as aPK.Foreign keys in
MySQLimplyInnoDBwhich is index-organized, this means that the table itself will be thePRIMARY KEYand it’s records will be ordered.If you are also going to search for
col2and usecol1in joins, you’ll need to create an additional secondary index on(col2). This index will implicitly include thePRIMARY KEYvalues as the record pointers, and, hence, will in fact be and index on(col2, col1, col2).