Multi-Column Primary Key in MySQL 5

Posted by Kaji on Stack Overflow See other posts from Stack Overflow or by Kaji
Published on 2010-04-15T04:41:51Z Indexed on 2010/04/15 4:43 UTC
Read the original article Hit count: 220

Filed under:
|
|
|
|

I'm trying to learn how to use keys and to break the habit of necessarily having SERIAL type IDs for all rows in all my tables. At the same time, I'm also doing many-to-many relationships, and so requiring unique values on either column of the tables that coordinate the relationships would hamper that.

How can I define a primary key on a table such that any given value can be repeated in any column, so long as the combination of values across all columns is never repeated exactly?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about keys