Master-master-detail 
Author Message
 Master-master-detail

Here's another question to field to those who piddle around with the
system more than they're supposed to :)

I've set up a master-master-detail table setup similar to this:

Table A (master of B and C):
  A_Key | A_Name

Table B (detail of A, master of D):
  B_Key | B_Name | A_Key

Table C (detail of A, also master of D):
  C_Key | C_Name | A_Key

Table D (detail of both B and C):
  D_Key | D_Name | B_Key | C_Key

It's reasonably easy to get table D set up with a parameterized query:

  select * from D
  where B_Key = :Master_B_Key
    and C_Key = :Master_C_Key

I set the parameters within the DataSOURCEs for B and C's OnDataChange
event, which fires almost always exactly when I want D to update, and
then I DisableControls, Close, Prepare, Open and EnableControls the
query.

This works just fine when I change records in either B or C (I'm using
DBGrids to correspond to all of the tables/queries), but when I change
records in table A, it fires off both B's and C's OnDataChange.  ONE
of the OnDataChanges happens before the other, however - so B's record
is right but C's is wrong or vice versa.

Is there a way to determine whether all the OnDataChanges that were
going to happen have happened?  I'd like to wait until the OnDataChanges
are all complete; is there another event that fires after all of them
have completed?

Thanks for any input you can provide :)

  --=- Ritchie Annand
  Doing things mom's database would be shocked to hear :)



Sun, 30 May 1999 03:00:00 GMT  
 Master-master-detail

Quote:

> Here's another question to field to those who piddle around with the
> system more than they're supposed to :)

> I've set up a master-master-detail table setup similar to this:

> Table A (master of B and C):
>   A_Key | A_Name

> Table B (detail of A, master of D):
>   B_Key | B_Name | A_Key

> Table C (detail of A, also master of D):
>   C_Key | C_Name | A_Key

> Table D (detail of both B and C):
>   D_Key | D_Name | B_Key | C_Key

> It's reasonably easy to get table D set up with a parameterized query:

>   select * from D
>   where B_Key = :Master_B_Key
>     and C_Key = :Master_C_Key

> I set the parameters within the DataSOURCEs for B and C's OnDataChange
> event, which fires almost always exactly when I want D to update, and
> then I DisableControls, Close, Prepare, Open and EnableControls the
> query.

> This works just fine when I change records in either B or C (I'm using
> DBGrids to correspond to all of the tables/queries), but when I change
> records in table A, it fires off both B's and C's OnDataChange.  ONE
> of the OnDataChanges happens before the other, however - so B's record
> is right but C's is wrong or vice versa.

I won't argue about your datamodel, supposing you have some very good
reasons to have build it like that. The problem being that you don't
know for sure in which order the OnDataChange events happen, I tried a
slightly different approach by linking the queries to their master's
datasources. For the last one, that is possible only on one, so I set
the other in the OnDataChange event of the second master. In other
words, I linked the second and third query to the first, the fourth to
the second by their datasource, changed the select statement to read
.. where B_Key = :B_Key ... and set :Master_C_Key in the OnDataChange
event of the third datasource. This way, there's only one OnDataChange
left and it seems to work, but that is on a very limited set (about
10-20 records in each table).

However, it's not very different from what you did, and I wonder what
the results would be on your own tables.

Jasper



Thu, 03 Jun 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Master-Detail : Sorting Detail?

2. Master - Detail - Detail queries & DBGrids

3. Setting report variables in the detail of a ReportSmith master-detail report

4. Master-detail-detail-detial with Cascade delete

5. Master/Detail lookup - losing detail field

6. Newbie - updating Detail in master-detail

7. HELP: Master-detail form: sequence of detail records

8. Sorting detail records in a master detail relation.

9. Problem when inserting records in the detail table (master/detail relation)

10. Different detail Index order within master-detail relationship

11. Master->Detail->Detail Query Too Slow

12. QuickReport Master/Detail reps with Details on the same page of the Master?

 

 
Powered by phpBB® Forum Software