Re: primary key debate
Posted in 2000
QuestionExchange wrote: > Always, always, always use a serial in anything except maybe > a detail record table, and even then, it should have the > serial from the master. SSN isn't even as unique as you > would think... I know people who during the course of the > imigration and naturalization process who have had multiple > SSNs. Nothing is for granted but your serial. Just to throw a monkey into the wrench ;-) even SERIAL/SERIAL8 is not totally safe. If you want to use EDR/CDR with update anywhere (ie peer-to-peer replication) then there is the possibility that two rows with the same serial may be inserted almost simultaneously on different servers. You need to use a SERIAL column PLUS another small key field indicating the source server id (a SMALLINT of short CHAR column will do). This combined key is guaranteed to be unique. If you are running on 9.2x you can create a fast cheap UDF to maintain the server id column. Otherwise you have to get creative. Art S. Kagel