Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
The right way
Message
De
24/09/2009 16:34:14
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
24/09/2009 15:06:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
01426003
Message ID:
01426019
Vues:
75
I wrote an article in Universal Thread Magazine, May 2002, outlining advantages of each approach.

I personally favor primary keys without business value (e.g., a serial number, or a GUID); one advantage is that the user can change "key" values (what the user sees as keys, such as client codes), without the database having to propagate those changes to scores of tables. Also, with keys that do have business value it is often difficult to find a unique combination - and combining several fields makes relations complicated. With serial numbers, you also save space. For example, an extra 4-byte field in the main table client in this example) is more than compensated by space savings in many records for each client, in several other tables, since the keys are usually shorter. (A GUID uses 16 bytes, so you may not save space - but a GUID has other advantages for distributed systems.)

While I personally dislike the other approach (using keys with business value), they do have their advantages as well, such as making debugging easier - in the "no business value" approach, you may have to do some additional lookups ("Who was client #5321, again?") Some claim that joining tables may be easier; for example, you already have the client number as a foreign key in the invoice table. But in this example, you will usually also need additional data for the client (like the full name).

>what's the right table structures for one-to-many forms?
>
>eg. for invoicing, I use:
> ...
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform