Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Database normalization
Message
De
26/01/2007 16:02:38
Mike Yearwood
Toronto, Ontario, Canada
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01189208
Message ID:
01189789
Vues:
10
Hi Russell

>I'd like to see the reasoning behind a multifield PK. I've always preferred a surrogate for the PK. If I understood what you meant in your parent-child-grandchild relationship example, then if the user scrolls through invoice header records for a parent, why can't you just query for the line items that belong to that invoice. I've certainly done things like that before. Quite fast with VFP, as I'm sure you know.

I'm glad you asked! You'd have to force the user to save all changes, before you could requery either the child or grandchild cursors.

With the FKs available throughout the hierarchy - you gain the ability to SET FILTER or SET KEY on the children/grand children as the user navigates without saving anything.

Admittedly this isn't the best example, because you'd seldom add a customer record and then add invoices and line items per invoice without saving, but with this approach you could do it!

>>I've been using surrogate/factless/meaningless keys for a long long time. I like the construction consistency, but I have recently seen what might be a flaw in the surrogate key for everything idea.
>>
>>If I have Companies, Invoices, and LineItems:
>>
>>
company
>>cmp_pk    cmp_name    cmp_cityfk
>>1         comp 1      1
>>2         comp 2      2
>>
>>
invhead
>>inv_pk    inv_no    inv_cmpfk
>>1         001       1
>>2         002       2
>>
>>
invline
>>lin_pk    lin_desc         lin_invfk
>>1         jam              1
>>2         peanut butter    2
>>
>>I cannot do a single form parent-child-grandchild relation because invline does not have the cmp_pk in it. It would be required for me to query all line items from invline and filter them as the user navigated among invhead records for a particular company.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform