RE: Unique constraint
Posted in 1999
From: William Raper <WilliamR@catmktg.com> > >Ahhh you're going to make me quote book, chapter and verse!!! > >2-166 Informix Guide to SQL: Syntax February 1998 >CREATE TABLE >Referenced and Referencing Column Requirements > >In a referential relationship, the referenced column is a column or set of >columns within a table that uniquely identifies each row in the table. In >other >words, the referenced column or set of columns must be a unique or >primary-key >constraint. If the referenced columns do not meet this criteria, the >database server returns an error. And a bit further on it says: "If you are referencing a primary key in another table, you do not have to state the primary-key columns in that table explicitly. Referenced tables that do not specify the referenced columns default to the primary-key columns. The references section of the previous example can be rewritten, as the following example shows: . . . FOREIGN KEY (ref_num, ref_type) REFERENCES accounts . . . Because acc_num and acc_type is the primary key of the accounts table, and no other columns are specified, the foreign key, ref_num and ref_type, references those columns." See, I was always a lazy b*st*rd, so I always define the PK and omit the column names in my syntax. And over the years, I've come to believe my way was the right way. <Slap, slap> Silly me. :-) ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com