Re: IS it a good practice to use SERIAL as Primary Key?

From: "Sander Steffann" <s(dot)steffann(at)computel(dot)nl>
To: "Ron Johnson" <ron(dot)l(dot)johnson(at)cox(dot)net>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: IS it a good practice to use SERIAL as Primary Key?
Date: 2006-11-23 18:38:39
Message-ID: 000d01c70f2e$98803600$64c8a8c0@balefirehome
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

>> Sure, but the check digit does not need to be stored, as it can be
>> regenerated on demand. The user interface just verifies the check
>> digit, then throws it away.
>
> $ SET GEEZER
> $ WRITE SYS$OUTPUT "THAT'S JUST EXTRA CYCLES WASTED BY THE"
> $ WRITE SYS$OUTPUT "CLIENT. BETTER TO USE THEM FOR SOME OTHER"
> $ WRITE SYS$OUTPUT "MORE PRODUCTIVE PURPOSE."
> $ SET NOGEEZER
>
> That's the VAX/VMS in me oozing out. But seriously, regenerate it
> on demand??? That's not how it works. This isn't a CRC or hash
> function.

Well, a check digit _is_ a kind of CRC. It is redundant information. For
every number there is only one correct check digit, which means that the
check digit does not add extra information to the number. So why store it?

You will need to add the check digit on most (all?) output that is
interpreted by humans. The software itself can just use the number itself
(assuming you don't need to check the integrity of the software).

If you store the number in the database, I would suggest making the db check
the number on all input too. Otherwise you might end up with invalid data in
the database.

- Sander

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2006-11-23 19:35:42 Re: COPY FROM : out of memory
Previous Message Stephen Harris 2006-11-23 18:18:06 Re: Shutting down a warm standby database in 8.2beta3