Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programmatically gathering indexs, keys & relationships
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00399648
Message ID:
00399674
Views:
17
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform