home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sunic!psinntp!psinntp!dlogics!hermes.dlogics.com!dlm
- From: dlm@hermes.dlogics.com
- Newsgroups: comp.databases.oracle
- Subject: On reversing the master-detail relationship.
- Message-ID: <1992Sep10.122259.1310@hermes.dlogics.com>
- Date: 10 Sep 92 12:22:59 CST
- References: <1992Sep3.163521.26698@cbfsb.cb.att.com> <1992Sep7.115156.1307@hermes.dlogics.com> <1992Sep8.122538.14511@cbfsb.cb.att.com>
- Organization: Datalogics, Inc., Chicago, IL
- Lines: 59
-
- colten@cbnewsb.cb.att.com (marc.colten) writes:
- > dlm@hermes.dlogics.com writes:
- >> colten@cbnewsb.cb.att.com (marc.colten) writes:
- >> > 3) Can you do a query on a detail block and have the relevant
- >> > information come up in the master block? [...]
- >> >
- >> [...] just write triggers that treat
- >> KEY-ENTQRY and KEY-EXEQRY in the detail exactly as if they are in the master,
- >> but with the block associations reversed.
- >
- > If I do a "go_block(master)" and then a query, it wipes out the
- > values of the master block and waits for input. I can't find a
- > function that takes the current values and runs with them.
-
- REVERSING THE MASTER-DETAIL RELATIONSHIP.
-
- The detail's foreign key is enforced from the master block primary key. The
- master is generally coded with no key enforcement. So, enforce its primary key
- from the detail block's foreign key. As long as the detail is cleared prior to
- querying the master, the master-detail will work; if the master is cleared
- prior to querying the detail, the detail-master will work. You will have to
- write the triggers yourself (cannibalize the master-detail procedures).
-
- The scenario will run something like this:
-
- master key-entqry go_block(detail);
- clear_block;
- go_block(master);
- enter_query;
- go_block(detail);
- execute_query; [not enter_query]
- go_block(master);
-
- detail key-entqry go_block(master);
- clear_block;
- go_block(detail);
- enter_query;
- go_block(master);
- execute_query; [ditto]
- go_block(detail);
-
- The same principle is employed for the case of key-exeqry. This is the
- simplest method i can think of.
-
- Remember most of all that the detail-master relation makes an end-run around
- the relational concept of key inheritance.
-
- If you do not query on a foreign key, the rows returned will belong to many
- masters. the behavior of the form is predictable: only one master will be
- returned since its primary key can be enforced from only one detail row. This
- presents a very misleading view of the relationship. If you solve this problem
- by querying only on the detail's foreign key, you will have accomplished
- little, since this action is the same as querying on the master's primary key.
-
- In short, although you can jury-rig the detail-master relationship, it is
- mostly pointless to do so. Net flames to /dev/nul or NLA0: please.
- --
- Dave Mausner, Senior Consultant / Datalogics Inc / Chicago IL / 312-266-4450
- dlm@dlogics.com Motto: Just show me the code
-