Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Persistent versus Temporary Relationships
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00307300
Message ID:
00307317
Views:
13
>I have been running into problems with using relationships that deal from parent to child. In other words if I am on a record in a parent table and then VFP automatically shows the records in the child table. This works great for me except if there are no child records that match. In this case the last record in the child table shows even though it doesn't match.
>
>Anyway, I have come to the conclusion that anytime I want this behavior I should use views which seem to work alot better. I have been asking alot of questions lately regarding generated pks and intelligent keys, composite indexes and single field indexes. I have also come to the conclusion, with alot of help from you guys, that I am going to use generated pk's in my child tables rather than intelligent keys like acct# etc. I do however need relationships then so that as I move through a child table the corresponding parent table has the correct record so that I can get pertinent information.

Keep in mind that child tables should have a foreign key field that contains the PK value of the parent table. This does not mean you have to create a persistent relationship.

>I am thinking about not using persistent relationships in the database container but instead...have a method in all of my forms where I can set temporary relationships for each form. Some of my tables can be quite large and there could be child, parent, grandparent and great grandparent relationships. Is this a wise scenario to be following? Is there a reason why I wouldn't want to be setting these temporary relations all over the place relating a child table to a parent table?

You can set relationships in the DE or programmatically with code in your forms. I do this quite often when I do not use views. IMHO, the primary reason to establish persistent relationships in the DBC if for RI [which you can still handle yourself programmatically]. However, if you do create a persistent relationship in the DBC, this does not obligate you to define RI constraints.

My developer nature leans toward being a control freak. So it takes me awhile to turn lose control over certain [new] aspects, features, etc., of VFP.
Mark McCasland
Midlothian, TX USA
Previous
Reply
Map
View

Click here to load this message in the networking platform