Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Programmatically gathering indexs, keys & relationships
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00399648
Message ID:
00399674
Vues:
24
>Thanks Neil,
>
>Do you know if there is a way to determine the type of relationship between tables listed in the array created by ADBOBJECTS(), like one-to-one, one-to-many, or many-to-many?

There is no internal function that I know of but you can create your own using the output of adbobjects(myarry,'relation') and the results from the primary(), candidate() and tagno() functions.

You can check to see if the parent index tag is a primary or candidate key. If it is, then you know you are dealing with a one to something relation. If not, then it is a many to something. Do the same for the child table. If it is a primary or candidate tag then it is a something to one relation.
for lxx = 1 to adbobjects(laobjects,'relation')
   use (laobjects[lxx,2]) in 0 alias ptable
   use (laobjects[lxx,1]) in 0 alias ctable
   ? iif(primary(tagno(laobjects[lxx,4],'','ptable')) or candidate(tagno(laobjects[lxx,4],'','ptable')),'One','Many') +;
      ' to ' + iif(primary(tagno(laobjects[lxx,3],'','ctable')) or candidate(tagno(laobjects[lxx,3],'','ctable')),'One','Many')
   use in ptable
   use in ctable
endfor
HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform