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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

no relation

Status
Not open for further replies.

engan

Programmer
Jul 15, 2001
53
ID
hi, I have a relation problem, I try to relate 3 table
table 1 relate to table 2
table 3 relate to table 2
when I look inside the database designer, it has the relation line. when I try to add table in dataenvironment, the relation line does not show up. Is this a bug or I have to set something before adding table in the dataenvironment ?
 
engan, the relation in the database is not what is the relation in the data environment. Relation in the database is a database object that help you to define table rules depended on the related table(s). this means cascade deleting of records from child tables when record in parent table is deleted, restriction of inserting record into child table when parent record does not exists etc. this is just for defining these rules. And this has nothing to the data environment.

Relation in the data environment is exactly OOP presentation of what SET RELATION and SET SKIP TO VFP commands do. They relate aliases so when parent table record moved, child record move also.

I also doubt it is useful to set up 2 parent tables for a single child table - it makes no sense from the logical point of view. If table 1 is customers, table 3 is warehouse items and table 2 is invoices, than table 2 will be parent for both. Set it as the main table in relation, than when you move record in that table, appropriate customer record and warehouse item record will be selected in table 1 and table 3.

Do you see difference?

Hope this helps.
Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
TomasDill, what I did is I try to recreate the form in the solution sample (1 to many form). It has orderitem, order and productid. when I open the dataenvironment then try to add order, orderitem it gives me the relation line, but when I try to add the third table (productid). It wont give me the relation line between productid and order. So when I look at the dataenvironment property, it has 3 cursors and only 1 relation defined. when I compare it with the original form 1 to many from solution sample, they have all relation line in their dataenvironment and there are 2 relations defined.

How do I add the relation for third table (between orderitem and productid) when I am in the dataenvironment screen ?
 
Hi Engan,

Is this what you're looking for:

Open the data environment, with your 3 tables showing.
Draw the relation line by dragging a field from one table onto an index in the other table.

Having 2 parent tables relating to one child table as you are trying to do, raises a couple of issues:

1) The child can only have one active index, so both parents will have to relate into the same child index.

2) when you look at the record in the table, how do you know if it is showing you the record related to parent1 or parent2?
The answer is, it will show the record related to the parent that most recently moved its record pointer:
Code:
Go top in "parent1"
   ? child.child_id &&Shows the child of parent1
Select parent2
   ? child.child_id 
   &&Still shows the child of parent1,
   &&because parent2 record pointer hasn't yet moved
Go recno() &&'Move' to the current record
   ? child.child_id &&Now it shows the child of parent2

After you've created the relations, you can see their properties in the using way in the properties window.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top