JoinDef Exercise
Objectives:
- Find out how to create a MASTER/DETAIL JoinDef.
- Learn how to edit the resulting default FORM for the JoinDef.
- Explore the 'Rules' that prevent update and/or deletion of records when
using JoinDefs.
- Create a JoinDef that will show the borrower details and the details of
any loans taken by particular borrowers.
- In Ingres/Menu Select f(8) the JoinDefs utility.
- Invoke the Create option to create a Blank JoinDef called
borrower_loans.
-
- Enter the following details under
Role, Table Name and
Abbreviation:
master, borrower, br
detail, loan, l
detail, copies, c
detail, book, bk
- leave the Table Field Format? flag set to YES and Go
f(8) the Join Definition. Don't worry about the nullable/ non-nullable
message.
This has created a joindef which will show, for each borrower the books they
have on loan. We've got borrower/loan as master detail, loan/copies as
detail/detail, and finally copies/book as another detail/detail. We need to
navigate through these tables to pick up appropriate information e.g. book title
from book.
- Once you have done this, test it using the RETRIEVE option in QBF.
- Once the JoinDef has been created Ingres assumes you want to run it and
drops you into the Execution phase of QBF for the JoinDef. You've already used
QBF on single tables so it should be vaguely familiar to you.
- Select the Retrieve option.
- Go f(8) a blank query and use NextMaster(f8) to scroll
through the borrowers.
- As you look at the form note how Ingres has dealt with the multiple
tables and see what data it is showing compared to the table definitions.
- End(f3) the retrieve function.
- End(f3) the QBF Execution Phase
- Save(f5) the JoinDef, leaving the option fields as they are.
- Now create a JoinDef called 'book_details' that shows book details, along
with the copy details and loan details for each book in the library. Test that
your JoinDef works by using QBF.
- Blank the JoinDef Definition Form.
- Repeat the above steps for the specified tables.
- Save(f5) the JoinDef.
- Set the Rules that prevent the user from DELETING both MASTER and DETAIL
rows in your JoinDef defined in 2).
- End(f3) the JoinDef Definition Form.
- From the JoinDefs Catalog select the book_details row and invoke the
Edit option.
- From the Join Definition Form invoke the Rules option.
- Change all the Delete? flags from 'yes' to 'no'.
- End(f3) the JoinDef Update & Delete Rules option and Go f(8) the
JoinDef again.
- Select the Update option.
- Go f(8) a blank query then try to Delete the first
record.
- See what message Ingres gives you. We've now created a form that allows
users to browse book details, but they cannot delete records, intentionally or
otherwise (in an application we may provide this function somewhere else).
Continue with trainer.
This WWW material is copyright De Montfort
University and may only be reproduced or used if this copyright notice is
included.
This page is maintained by John Skelton. Comments or
suggestions for improving this material can be emailed to jas@dmu.ac.uk) and will be gratefully received.