Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux