[comp.databases] Permanent, automatic surrogate keys

davek@rtech.rtech.com (Dave Kellogg) (06/26/89)

In article <...> Emuleomo (emuleomo@yes.rutgers.edu) writes:
>
>IS THERE A WAY TO IMPLEMENT a SERIAL fld in Ingres (as is done in Informix)??

Not one which meets all of your criteria.  If you read the technical notes
in the [ingres.notes] directory (VAX/VMS) or ~ingres/notes (UNIX) under the
topic of TIDS (tuple identifiers), you'll find the construct that comes 
closest.

Tids meet several, but not all, of the criteria in your definition.

a) They uniquely identify a row in a relation

b) [kind of independent of a], they provide lightning fast access to a row
   which is better than a btree/isam key and as fast as a HASH primary. 
   (Faster than btree/isam b/c no index need be traversed, about as good
   as HASH, because the TID will send you straight to the right page just
   like a HASH key).

c) Tids are generated/managed entirely by the DBMS.

d) Tids, however, can change and a given row is not guaranteed to have the
   same tid forever.  Most common cause for a tid's changing is if the row
   moves within the table.  (e.g. changing value of primary key, modifying
   the table to different storage structure, replacing a compressed data row
   with data too big to fit back on the same page.)



My question, out of curiosity, is don't you have a good primary key that
you can use?  And, what/how would you use these permanent [automatic]
surrogate keys?  If you do need them, I'd suggest managing your own surrogate
key field and making that a primary (or probably better off as) HASHed
secondary key.



Dave Kellogg
RTI New York City