Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Primary Index
Message
De
14/12/1999 05:54:00
Paul Frost
Instem Computer Systems Ltd
Stone, Royaume Uni
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00300125
Message ID:
00303220
Vues:
25
>>I agree with the arguments relating to auditing & not reusing PKs, but if the version/revision are guaranteed to be unique, why not generate a PK based on the 2 values ? If I were designing a manual filing system, I would naturally try to file in order on something relevant to the document - making it easy to locate, in this case version/revision, just because it's a database system why do something different ? To my mind it seems to be 1 extra table to maintain, on top of any tables (procedures/whatever) to ensure unique version & revision numbering.
>
>Paul,
>
>Here's an answer. The purpose of a primary key is not to make an ordering of data for you and I, it is to allow the computer to connect records from two tables to each other. The computer has no idea what the meaning of the data is (the difference between data and information) and it doesn't care. Computers are very fast at processing integer numbers and they love them, especialy if we limit them to 1's and 0's. So for the most efficient method of allowing a computer to shlop through our records and connect them up correctly it is advisable to use integers.
>
>Second reason, as soon as the primary key has meaning to a human being, they will want to change its value. "Oh damn, I put that in as revision 7 and it was really revision 8, I'll have to change that." Now you, the database programmer, must insure that the change in value of the primary key does not cause any orphaned related records anywhere. It may as simple as one other table, but it could be a whole slew of other tables that are involved.
>
>With a surrogate PK (integer) you can let the user change the revision number and not give any thought to the related records because your primary key is not seen by the user, it has no meaning to the user, and it is strictly maintained by the computer, of the computer, and for the computer. Gee that last phrase sounds familiar :-).

Thanks to everyone who responded after I hijacked the thread (I think I was trying to get around the problem of packing the database in the first place). It's helped my thinking about PK's. Walter Meester has let me know that there is no real reason why a PK shouldn't be generated from data in fields (I would make sure that it turned out to be an integer, to keep the speed up) - but Peter Robinson made a very valid point about having multiple system for PK generation when 1 would do.

Thanks especially to Jim for his brief lecture in computer basics - I must remember to ensure that any integers I store use only 1's & 0's - but does that restriction apply to other data types too ? (I'm only a beginner at relational database design - I have been programming for close to 20 years)

Thanks again,
Paul
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform