[thelist] MySQL table structures with PHP

rudy r937 at interlog.com
Wed Jan 22 14:51:01 CST 2003


> cw_ColorxItem
>          cw_ID int auto_increment
>          ItemID int
>          ColorID int

good stuff, anthony, that's your basic many-to-many relationship table

just a comment in passing, if you don't mind  --

that surrogate key (auto_increment column) is totally unnecessary

make the pair of foreign keys the primary key

that way, you eliminate the possibility of linking the same item to the same
colour more than once, which, with the surrogate key, you can only achieve
by declaring a separate unique key on the pair of columns, an extra index in
addition to the default one which the surrogate gets as the primary key


rudy




More information about the thelist mailing list