Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

question about setting relationships in database vfp 6.0

Status
Not open for further replies.

Judi201

Technical User
Jul 2, 2005
315
US
Hi,

I have a DB with one master table and four child tables related by customerid. In the DB I set the relationship from primary master index to child index in each. When I create a form and add the data environment, it is represented as master customerid field to child index. It seems to work, and I realize that the index was built on the field, but I don't understand why it appears one way when I open the DB from the project modify and looks different when I add it to a form. Any comments? My concern is that I might somehow have two different things going on an not know it. I am trying to learn to use the 'nice features' of OOP. VFP 6.0

Thanks for any input.

Judi
 

Hi Judi,

First thing you need to know is - you don't need to worry. What you are seeing is normal and it won't cause your form to mis-behave.

I think we discussed a similar question in another thread. I made the point that setting a persistent relationship in the database designer does not impact your code in any way. Persistent relationships are more like documentation -- they tell you -- the developer -- what the relationship is, but they don't change the way your tables are accessed.

That said, persistent relationships serve another role -- they define the default relationships that you see in the data environment of forms, and also in the query and view designers. These are only defaults -- you can change them in the DE without affecting the database.

The main point is that, if you see the relationship in the DE, the form will respect that relationship.

As far as indexes is concerned, in a relationship in the DE (or in program code) the child table must have an index on the related field. VFP won't let you create a relationship in the DE if this is not the case. The parent table does not have to have an index on the related field. This is in contrast to the relationships in the database designer, where you need an index on both sides. I'm not really sure why this is so.

I hope this helps.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Mike,

they define the default relationships that you see in the data environment of forms

Thanks for your response.

It was the previous discussion on this that worried me because to me default relationship meant that when I added the DB to the form's DE, it would appear as the same - index to index, but I could change that or use whatever part of it that I needed. I know I am failing to 'get' something here but with your assurance I will leave it and go on. I know that it will fall into place with more experience. I do have to put this in a critical work environment so I don't want the DB management setup to be flawed.

Moving on!!

Judi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top