Re: Q: PRIMARY KEY vs UNIQUE constraint
Posted in 1996
CRAIG@CHEMISTRY.CHEM.UTAH.EDU wrote: > > The primary key attribute is needed if other tables will be using > foreign keys to refer to it. You're right, if you're just looking > at one table, then unique keys and primary keys seems to be the same. > It's when you look at multiple tables and are trying to enforce > referential constraints that the difference appears. > > --Craig (craig@chemistry.utah.edu) > } > }What is the benefit in defining the structure of a table as a PRIMARY-KEY vs > }a UNIQUE constraint in an Informix database? In other words, (I have looked > }in the manuals but could not find anything), how does Informix treat the > }PRIMARY-KEY differently than a UNIQUE constraint? They both use a unique > }index and seem to be different only in the table sysconstraint's constraint > }type (I forget the column name). > } You can build a referencial constraint referencing a set of columns that have only a unique constraint on them. It does not have to be a primary key constraint. However, a table can have only one primary key constraint but more than one unique constraint. The set of columns making up the primary key can not have a null value in them, however, if it was a unique constraint, 1 occurence of nulls is allowed. regards - - Atul.