Re: Does it make sense to have 2 unique keys in one table?
Posted in 1995
Topics: General Discussion
In article <812935325.2008@ttyrwhit.demon.co.uk>, tonytd@ttyrwhit.demon.co.uk (Tony Tyrwhitt-Drake) wrote: > From a logical viewpoint, I would have thought that a unique key > is a primary key, and logically there should only be one primary > key per table / entity. This is a common misconception, i.e., that "unique key" = "primary key". They're actually two different things. Any given table can have several unique keys, but it can only have one _primary_ key. For example, an employee might have an employee number and a social security number, both of which are unique keys (known in relational theory as _candidate keys_). Which one you use as the primary key is a matter of choice. I know this is a little off-topic, but I couldn't let that one go by -- after all, I teach this stuff ;) ===================================================================== Nigel Stanger, Internet: nigel.stanger@stonebow.otago.ac.nz University of Otago, Phone: +64 3 479-8179 Dunedin, NEW ZEALAND. Fax: +64 3 479-8311