Databases Reference
In-Depth Information
3. To set the relationship between PUBLISHERS and BOOKS, place the mouse
pointer over the PubID attribute name in the PUBLISHERS table scheme, hold
down the left mouse button, and drag the name to the PubID attribute name in the
BOOKS table scheme. You should get a window similar to Figure 3-5.
Figure 3-5. Relationship between the PUBLISHERS and BOOKS tables
4. This window shows the relationship between PUBLISHERS and BOOKS, listing
the key {PubID} in PUBLISHERS and the foreign key {PubID} in BOOKS. (We
did not need to call the foreign key PubID, but it makes sense to do so, since it
reminds us of the purpose of the attribute.)
5. Now check the Enforce Referential Integrity box, and click the Create button.
You should get the message in Figure 3-6. The problem is, of course, the dangling
reference that we created by changing the PubID field in the BOOKS table to
refer to a nonexistent publisher.
Figure 3-6. Error message due to dangling reference
6. Click the OK button, reopen the BOOKS table, and fix the offending entry
(change the PubID field for Hamlet back to 2). Then close the BOOKS table, and
re-establish the relationship between PUBLISHERS and BOOKS. This time,
Search WWH ::




Custom Search