How to properly create composite primary keys - MYSQL -


here gross oversimplification of intense setup working with. table_1 , table_2 both have auto-increment surrogate primary keys id. info table contains information both table_1 , table_2.

table_1 (id, field)   table_2 (id, field, field) info ( ???, field) 

i trying decided if should make primary key of info composite of ids table_1 , table_2. if this, of these makes sense?
( in example combining id 11209 id 437 )

int(9) 11209437 (i can imagine why bad)
varchar (10) 11209-437
decimal (10,4) 11209.437

or else?

would fine use primary key on mysql myisam db?

i use composite (multi-column) key.

create table info (     t1id int,     t2id int,     primary key (t1id, t2id) )  

this way can have t1id , t2id foreign keys pointing respective tables well.


Comments