Re: unique key - primary key
I have two tables, seemigly very similar setup; the primary key is the combination of two columns. With mysqldump, however, the table definition of the two tables looks different. Mysqldump on table 1 says ... UNIQUE KEY HONstid (HONstid,HONname) whereas on table 2 it says ... PRIMARY KEY (IMstid,IMfnum) What is the difference? Is there any? A table can have only 1 primary key, but multiple unique constraints. And columns in primary keys must be NOT NULL. Columns in unique keys can be NULL (if they are NOT NULL, then the unique key is functionally the same as a primary key). Ah yes Paul, thanks for adding that. With regards, Martijn Tonies Database Workbench - developer tool for InterBase, Firebird, MySQL MS SQL Server Upscene Productions http://www.upscene.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: unique key - primary key
Hello, RE: And columns in primary keys must be NOT NULL. Columns in unique keys can be NULL (if they are NOT NULL, then the unique key is functionally the same as a primary key). OK, thanks guys for the explanation. Then the result of mysqldump table definition part: UNIQUE KEY HONstid (HONstid,HONname) means that I have two unique keys: HONstid and also the (HONstid,HONname) combination? No, as far as I can tell, this means you have a unique constraint named HONstid for columns HONstid,HONname This does not make too much sense; if I can have only one HONstid in my table, then of course i can have only one kind of (HONstid,HONname) combination. In the actual table, I have multiple occurences of values (HONstid,HONname)in the HONstid column, i.e. it does not seem like HONstid in itself was a unique key. Only the (HONstid,HONname) combination is unique. With regards, Martijn Tonies Database Workbench - developer tool for InterBase, Firebird, MySQL MS SQL Server Upscene Productions http://www.upscene.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
unique key - primary key
Hi, I have two tables, seemigly very similar setup; the primary key is the combination of two columns. With mysqldump, however, the table definition of the two tables looks different. Mysqldump on table 1 says ... UNIQUE KEY HONstid (HONstid,HONname) whereas on table 2 it says ... PRIMARY KEY (IMstid,IMfnum) What is the difference? Is there any? Table1: mysql desc table1; ... | HONstid | int(3)| | PRI | 1| | | HONname | char(20) | | PRI | standard | | ... Table2: mysql desc table2; ... | IMstid | int(3) | | PRI | 0 | | | IMfnum | int(6) | | PRI | 0 | | ... A general question: is there a difference between a primary key and a unique key, or they are synonims? Cheers Gaspar -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: unique key - primary key
Hello, I have two tables, seemigly very similar setup; the primary key is the combination of two columns. With mysqldump, however, the table definition of the two tables looks different. Mysqldump on table 1 says ... UNIQUE KEY HONstid (HONstid,HONname) whereas on table 2 it says ... PRIMARY KEY (IMstid,IMfnum) What is the difference? Is there any? A table can have only 1 primary key, but multiple unique constraints. With regards, Martijn Tonies Database Workbench - developer tool for InterBase, Firebird, MySQL MS SQL Server Upscene Productions http://www.upscene.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: unique key - primary key
At 22:27 +0100 12/28/04, Martijn Tonies wrote: Hello, I have two tables, seemigly very similar setup; the primary key is the combination of two columns. With mysqldump, however, the table definition of the two tables looks different. Mysqldump on table 1 says ... UNIQUE KEY HONstid (HONstid,HONname) whereas on table 2 it says ... PRIMARY KEY (IMstid,IMfnum) What is the difference? Is there any? A table can have only 1 primary key, but multiple unique constraints. And columns in primary keys must be NOT NULL. Columns in unique keys can be NULL (if they are NOT NULL, then the unique key is functionally the same as a primary key). -- Paul DuBois, MySQL Documentation Team Madison, Wisconsin, USA MySQL AB, www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: unique key - primary key
Hi, RE: And columns in primary keys must be NOT NULL. Columns in unique keys can be NULL (if they are NOT NULL, then the unique key is functionally the same as a primary key). OK, thanks guys for the explanation. Then the result of mysqldump table definition part: UNIQUE KEY HONstid (HONstid,HONname) means that I have two unique keys: HONstid and also the (HONstid,HONname) combination? This does not make too much sense; if I can have only one HONstid in my table, then of course i can have only one kind of (HONstid,HONname) combination. In the actual table, I have multiple occurences of values (HONstid,HONname)in the HONstid column, i.e. it does not seem like HONstid in itself was a unique key. Only the (HONstid,HONname) combination is unique. Cheers Gaspar p.s.: Paul, I very much enjoy your MySQL book. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]