Joe Celko's SQL for Smarties: Advanced SQL Programming, Third Edition

1.2: Generating Unique Sequential Numbers for Keys

1.2 Generating Unique Sequential Numbers for Keys

One common vendor extension is using some method of generating a sequence of integers to use as primary keys. These are very nonrelational extensions that are highly proprietary, and have major disadvantages. They all are based on exposing part of the physical state of the machine during the insertion process, in violation of Dr. E. F. Codd's rules for defining a relational database (i.e., rule 8, physical data independence). Dr. Codd's rules are discussed in Chapter 2.

Early SQL products were built on existing file systems. The data was kept in physically contiguous disk pages, in physically contiguous rows, made up of physically contiguous columns, in short, just like a deck of punch cards or a magnetic tape. Most of these sequence generators are an attempt to regain the physical sequence that SQL took out of its logical model, so we can pretend that we have physically contiguous storage.

But physically contiguous storage is only one way of building a relational database, and it is not always the best one. Aside from that, the whole idea of a relational database is that user is not supposed to know how things are stored at all, much less write code that depends on the particular physical representation in a particular release of a particular product.

The exact method used to generate sequences of integers varies from product to...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Database Tools Software
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.