Re: Primary Key Theory Question
Date: Tue, 30 Mar 2004 17:47:15 -0300
Em Sun, 28 Mar 2004 21:53:07 +0000, Ben escreveu:
> _how_ does one
> generate a surrogate key that is a) unique and b) usable from an
> application programmer's point of view.
For the programmers, SEQUENCEs are about as good as it gets. PostgreSQL's serial is also good. I am not familiar with SQL Servers' identity...
Now obviously any surrogate key alone *is* a recipe for disaster. That's why one needs still to implement uniqueness constraints for the natural candidate keys. Surrogates are only to keep programmers and users from whining about composite keys.
> sequences and Identity columns are great from an application developers
> point of view because you have easy access to the key of a newly created
Sequences are nice too, SELECT sequence.nextval FROM dual;
-- Leandro Guimar„es Faria Corsetti Dutra <leandro_at_dutra.fastmail.fm> MaringŠ, PR, BRASIL http://br.geocities.com./lgcdutra/ Soli Deo Gloria!Received on Tue Mar 30 2004 - 22:47:15 CEST