i'm being told more than one primary key is too many.
i need a set of things to be unique in three tables.. i've noticed i can call things either "unique" or "unique key"
i have questions....
1: what's the difference between those?
2: why have i seen examples where you end a line with "primary key" but none like that with "unique" or "unique key", and the only ones with unique are indexes?
3: why does "unique" have to have a name and a feild? is there a way to get it like making a primary key like when you define it inline (and why do i get the feeling that is what the difference between "unique" and "unique key" is)?
key questions
Moderator: General Moderators
Re: key questions
Instead of me mumbling away... (probably easier reading it from the source)
Example of unique fields are username, accountnumbers...
Example of keys/primary are userid, some counters...
http://www.mysql.com/doc/en/CREATE_TABLE.htmlThe Manual wrote:In MySQL, a UNIQUE key can have only distinct values. An error occurs if you try to add a new row with a key that matches an existing row.
A PRIMARY KEY is a unique KEY where all key columns must be defined as NOT NULL. If they are not explicitly declared as NOT NULL, it will be done implicitly (and quietly). In MySQL the key is named PRIMARY. A table can have only one PRIMARY KEY. If you don't have a PRIMARY KEY and some applications ask for the PRIMARY KEY in your tables, MySQL will return the first UNIQUE key, which doesn't have any NULL columns, as the PRIMARY KEY.
... and so on, and so on...
Example of unique fields are username, accountnumbers...
Example of keys/primary are userid, some counters...