student-ch03-relational-model--char-solutions
student-ch03-relational-model--char-solutions
A table, a logical structure that represents an entity set, is only one of the components of a database.
The database is a structure that houses one or more tables and metadata. The metadata are data
about data. Metadata include the data (attribute) characteristics and the relationships between the
entity sets.
Entity integrity and referential integrity are important because they are the basis for expressing and
implementing relationships in the entity relationship model. Entity integrity ensures that each row is
uniquely identified by the primary key. Therefore, entity integrity means that a proper search for an
existing tuple (row) will always be successful. (And the failure to find a match on a row search will
always mean that the row for which the search is conducted does not exist in that table.) Referential
integrity means that, if the foreign key contains a value, that value refers to an existing valid tuple
(row) in another relation. Therefore, referential integrity ensures that it will be impossible to assign
a non-existing foreign key value to a table.
Each attribute is a named column within the relational table and draws it values from a domain. A
domain is a set of all the possible values for this attribute.
7. Create the basic ERD using UML notation for the database shown in Figure Q3.2.
For use with Database Principles, Second Edition, Cengage Learning EMEA
Figure Q3.7 UML ERD Solution for Question 7
9. What are homonyms and synonyms, and why should they be avoided in database design?
Homonyms appear when more than one attribute has the same name. Synonyms exist when the
same attribute has more than one name. Avoid both to avoid inconsistencies. For example, suppose
we check the database for a specific attribute such as NAME. If NAME refers to customer names as
well as to sales rep names, a clear case of a homonym, we have created an ambiguity, because it is
no longer clear which entity the NAME belongs to.
Synonyms make it difficult to keep track of foreign keys if they are named differently from the
primary keys they point to. Using REP_NUM as the foreign key in the CUSTOMER table to
reference the primary key REP_NUM in the SALESREP table is much clearer than naming the
CUSTOMER table's foreign key SLSREP. The proliferation of different attribute names to describe
the same attributes will also make the data dictionary more cumbersome to use.
Some data RDBMSes let the data dictionary check for homonyms and synonyms to alert the user to
their existence, thus making their use less likely. For example, if a CUSTOMER table contains the
(foreign) key REP_NUM, the entry of the attribute REP_NUM in the SALESREP table will either
cause it to inherit all the characteristics of the original REP_NUM, or it will reject the use of this
attribute name when different characteristics are declared by the user.
11. Identify and describe the components of the table shown in Figure Q3.4, using correct
terminology. Use your knowledge of naming conventions to identify the table’s probable
foreign key(s).
For use with Database Principles, Second Edition, Cengage Learning EMEA
FIGURE Q3.11The Ch03_NoComp Database EMPLOYEE Table
Problem Solutions
Use the database shown in Figure P3.1 to work Problems 1-7. Note that the database is composed
of four tables that reflect these relationships:
• An EMPLOYEE has only one JOB_CODE, but a JOB_CODE can be held by many
EMPLOYEEs.
• An EMPLOYEE can participate in many PLANs, and any PLAN can be assigned to many
EMPLOYEEs.
Note also that the *:* relationship has been broken down into two 1:* relationships for which the
BENEFIT table serves as the composite or bridge entity.
For use with Database Principles, Second Edition, Cengage Learning EMEA
FIGURE P3.1 The Ch03_BeneCo Database Tables
EMP_CODE PLAN_CODE
15 2
15 3
16 1
17 1
17 3
17 4
20 3
JOB_CODE JOB_DESCRIPTION
1 Clerical
2 Technical
3 Managerial
PLAN_CODE PLAN_DESCRIPTION
1 Term life
2 Stock purchase
3 Long-term disability
4 Dental
For use with Database Principles, Second Edition, Cengage Learning EMEA
1. For each table in the database, identify the primary key and the foreign key(s). If a table does
not have a foreign key, write None in the assigned space provided.
3.Do the tables exhibit entity integrity? Answer yes or no; then explain your answer.
For use with Database Principles, Second Edition, Cengage Learning EMEA
5. Create the ERD using Crow’s Foot notation to show the relationships among EMPLOYEE,
BENEFIT, JOB, and PLAN.
For use with Database Principles, Second Edition, Cengage Learning EMEA
Use the database shown in Figure P3.7 to answer Problems 7-13.
REGION_CODE REGION_DESCRIPT
1 East
2 West
For use with Database Principles, Second Edition, Cengage Learning EMEA
7. For each table, identify the primary key and the foreign key(s). If a table does not have a
foreign key, write None in the space provided.
9. Do the tables exhibit referential integrity? Answer yes or no; then explain your answer. Write
NA (Not Applicable) if the table does not have a foreign key.
11. Create the ERD using UML notation to show the relationship between STORE and
REGION.
The UML ERD is shown in Figure P3.11. Note that each store is located in a single region, but that
each region can have many stores located in it. (It’s always a good time to focus a discussion on the
role of business rules in the creation of a database design.)
13. Draw the ERD to show the relationships among EMPLOYEE, STORE, and REGION.
The UML ERD is shown in Figure P3.13. Remind students that you always read from the “1” side
to the “*” side in any 1:* relationship, i.e., a STORE employs many EMPLOYEEs and a REGION
contains many STORES. In a 1:1 relationship, you always read from the “parent” entity to the
related entity. In this case, only one EMPLOYEE manages each STORE … and each STORE is
managed by only one EMPLOYEE.
We have shown Figure P3.13’s Visio Professional-generated ERD to include the properties of the
manages relationship. Note that there is no mandatory 1:1 relationship available at this point. That’s
For use with Database Principles, Second Edition, Cengage Learning EMEA
why there is an optional relationship represented by 0:1 next to the STORE entity to indicate that an
employee is not necessarily a manager. Let your students know that such optional relationships will
be explored in detail in Chapter 5. If you use Microsoft Visio Professional, let your students use the
Visio tutorial in Appendix A, located in the book’s Student CD-ROM Companion.
For use with Database Principles, Second Edition, Cengage Learning EMEA
Table name: VENDOR Primary Key: VEND_CODE
15. Do the tables exhibit entity integrity? Answer yes or no; then explain your answer.
17. Create the ERD using UML notation for this database.
NOTE
In this case, we assume that each product is supplied by a single vendor. It is, of course,
possible for a situation to exist in which a vendor can supply many products and each
product can be supplied by many vendors. In this latter scenario, there exists a *:*
relationship between VENDOR and PRODUCT. This *:* relationship must then be
decomposed into two sets of 1:* relationships, thus requiring the creation of a third table
structure (a composite entity) to form the "bridge" between VENDOR and PRODUCT.
We will explore such relationships in greater detail in Chapter 5.
For use with Database Principles, Second Edition, Cengage Learning EMEA
FIGURE P3.19 The Ch03_TransCo Database Tables
TYPE_CODE TYPE_DESCRIPTION
1 Single box, double-axle
2 Single box, single-axle
3 Tandem trailer, single-axle
For use with Database Principles, Second Edition, Cengage Learning EMEA
19. For each table, identify the primary key and the foreign key(s). If a table does not have a
foreign key, write None in the space provided.
NOTE
Note: The TRUCK_SERIAL_NUM could also be designated as the primary key. Because the
TRUCK_NUM was designated to be the primary key, TRUCK_SERIAL_NUM is an
example of a candidate key.
21. Do the tables exhibit referential integrity? Answer yes or no; then explain your answer. Write
NA (Not Applicable) if the table does not have a foreign key.
NOTE
Some of the answers to the following problem 23 define only a few of the available correct
choices. For example, a superkey is, in effect, a candidate key containing redundant
attributes. Therefore, any primary key plus any other attribute(s) is a superkey.
Because a secondary key does not necessarily yield unique outcomes, the number of
attributes that constitute a secondary key is somewhat arbitrary. The adequacy of a
secondary key depends on the extent of the end-user's willingness to accept multiple
matches.
For use with Database Principles, Second Edition, Cengage Learning EMEA
23. For each table, identify a superkey and a secondary key.
BASE_CODE + BASE_CITY + BASE_CITY (This a very effective secondary key, since it is not
likely that a state contains two cities with the same
name.)
CHAR_ CHAR_D CHAR_ CHAR AC_NUM CHAR_DES CHAR_DI CHAR_ CHAR_ CHAR_FUEL CHAR CUS_
TRIP ATE PILOT _COPI BER TINATION STANCE HOURS HOUR _GALLONS _OIL_ CODE
LOT _FLOW S_WAI QTS
N T
10001 05-Feb-08 104 2289L CDG 936.00 5.1 2.2 354.1 1 10011
10002 05-Feb-08 101 2778V BNA 320.00 1.6 0 72.6 0 10016
10003 05-Feb-08 105 109 4278Y LHR 1,574.00 7.8 0 339.8 2 10014
10004 06-Feb-08 106 1484P CPT 472.00 2.9 4.9 97.2 1 10019
10005 06-Feb-08 101 2289L CDG 1,023.00 5.7 3.5 397.7 2 10011
10006 06-Feb-08 109 4278Y CPT 472.00 2.6 5.2 117.1 0 10017
10007 06-Feb-08 104 105 2778V LHR 1,574.00 7.9 0 348.4 2 10012
10008 07-Feb-08 106 1484P TYS 644.00 4.1 0 140.6 1 10014
10009 07-Feb-08 105 2289L LHR 1,574.00 6.6 23.4 459.9 0 10017
10010 07-Feb-08 109 4278Y CDG 998.00 6.2 3.2 279.7 0 10016
10011 07-Feb-08 101 104 1484P BNA 352.00 1.9 5.3 66.4 1 10012
10012 08-Feb-08 101 2778V MOB 884.00 4.8 4.2 215.1 0 10010
10013 08-Feb-08 105 4278Y TYS 644.00 3.9 4.5 174.3 1 10011
10014 09-Feb-08 106 4278Y CDG 936.00 6.1 2.1 302.6 0 10017
10015 09-Feb-08 104 101 2289L LHR 1,645.00 6.7 0 459.5 2 10016
10016 09-Feb-08 109 105 2778V MQY 312.00 1.5 0 67.2 0 10011
10017 10-Feb-08 101 1484P CPT 508.00 3.1 0 105.5 0 10014
10018 10-Feb-08 105 104 4278Y TYS 644.00 3.8 4.5 167.4 0 10017
For use with Database Principles, Second Edition, Cengage Learning EMEA
The destinations are indicated by standard three-letter airport codes. For example,
In a fully developed system, such attribute values would be updated by application software when
Customers are charged per round-trip mile, using the MOD_CHG_MILE rate. The MOD_SEAT
gives the total number of seats in the airplane, including the pilot and copilot seats. Therefore a
PA31-350 trip that is flown by a pilot and copilot has six passenger seats available.
For use with Database Principles, Second Edition, Cengage Learning EMEA
Table name: PILOT
The pilot licenses shown in the PILOT table include the ATP = Airline Transport Pilot and COM =
Commercial Pilot. Businesses that operate on demand air services are governed by Part 135 of the
Federal Air Regulations (FARs) that are enforced by the Federal Aviation Administration (FAA).
Such businesses are known as “Part 135 operators.” Part 125 operations require that pilots
successfully complete flight proficiency checks every six months. The “Part 135” flight proficiency
check data is recorded in PIL_PT135_DATE. To fly commercially, pilots must have at least a
For use with Database Principles, Second Edition, Cengage Learning EMEA
Table name: CUSTOMER
ROBCOR is an aircraft charter company that supplies on-demand charter flight services, using a
fleet of four aircraft. Aircraft are identified by a (unique) registration number. Therefore, the
aircraft registration number is an appropriate primary key for the AIRCRAFT table.
The nulls in the CHARTER table’s CHAR_COPILOT column indicate that a copilot is not
necessarily required for some charter trips or for some aircraft. (Federal Aviation Administration
(FAA) rules require a copilot on jet aircraft and on aircraft having a gross take-off weight over
12,500 pounds. None of the aircraft in the AIRCRAFT table is governed by this requirement;
however, some customers may require the presence of a copilot for insurance reasons.) All charter
trips are recorded in the CHARTER table.
NOTE
Earlier in the chapter it was stated that it is best to avoid homonyms and synonyms. In this
problem, both the pilot and the copilot are pilots in the PILOT table, but EMP_NUM cannot be
used for both in the CHARTER table. Therefore, the synonyms CHAR_PILOT and
CHAR_COPILOT were used in the CHARTER table.
Although the “solution” works in this case, it is very restrictive and it generates nulls when a
copilot is not required. Worse, such nulls proliferate as crew requirements change. For
example, if the AviaCo charter company grows and starts using larger aircraft, crew
requirements may increase to include flight engineers and load masters. The CHARTER table
would then have to be modified to include the additional crew assignments; such attributes as
CHAR_FLT_ENGINEER and CHAR_LOADMASTER would have to be added to the
CHARTER table. Given this change, each time a smaller aircraft flew a charter trip without
the number of crew members required in larger aircraft, the “missing” crew members would
yield additional nulls in the CHARTER table.
You will have a chance to correct those design shortcomings in Problem 28. The problem
illustrates two important points:
1. Don’t use synonyms. If your design requires the use of synonyms, revise the design!
2. To the greatest possible extent, design the database to accommodate growth without
requiring structural changes in the database tables. Plan ahead—and try to anticipate
the effects of change on the database.
For use with Database Principles, Second Edition, Cengage Learning EMEA
25. For each table, where possible, identify:
b. A superkey
TABLE SUPER KEY
CHARTER CHAR_TRIP + CHAR_DATE
AIRCRAFT AC_NUM + MOD-CODE
MODEL MOD_CODE + MOD_NAME
PILOT EMP_NUM + PIL_LICENSE
EMPLOYEE EMP_NUM + EMP_DOB
CUSTOMER CUS_CODE + CUS_LNAME
For use with Database Principles, Second Edition, Cengage Learning EMEA
c. A candidate key
TABLE CANDIDATE KEY
CHARTER No practical candidate key is available. For example,
will still not necessarily yield unique matches, because it is possible to fly
an aircraft to the same destination twice on one date with the same pilot and
copilot. You could, of course, present the argument that the combination of
all the attributes would yield a unique outcome.
AIRCRAFT See the previous discussion.
MODEL See the previous discussion.
PILOT See the previous discussion.
EMPLOYEE See the previous discussion. But Perhaps the combination of
e. A secondary key
TABLE SECONDARY KEY
CHARTER CHAR_DATE + AC_NUMBER + CHAR_DESTINATION
AIRCRAFT MOD_CODE
MODEL MOD_MANUFACTURER + MOD_NAME
PILOT PIL_LICENSE + PIL_MED_DATE
EMPLOYEE EMP_LNAME + EMP_FNAME + EMP_DOB
CUSTOMER CUS_LNAME + CUS_FNAME + CUS_PHONE
For use with Database Principles, Second Edition, Cengage Learning EMEA
26. Create the ERD using UML notation. (Hint: Look at the table contents. You will discover that
an AIRCRAFT can fly many CHARTER trips, but each CHARTER trip is flown by one
AIRCRAFT. Similarly, you will discover that a MODEL references many AIRCRAFT, but
each AIRCRAFT references a single MODEL, etc.)
The UML ERD is shown in Figure P3.26. The optional (default) 1:1 relationship crops up in this
ERD and also note that EMPLOYEE is the “parent” of PILOT.
Note that all pilots are employees, but not all employees are pilots – some are mechanics,
accountants, and so on. (This discussion previews some of the Chapter 5 coverage … coming
attractions, so to speak.) The relationship between PILOT and EMPLOYEE is read from the
“parent” entity to the related entity. In this case, the relationship is read as “an EMPLOYEE is a
PILOT.”
For use with Database Principles, Second Edition, Cengage Learning EMEA
27. Modify the ERD you created in Problem 26 to eliminate the problems created by the use
of synonyms. (Hint: Modify the CHARTER table structure by eliminating the CHAR_PILOT
and CHAR_COPILOT attributes; then create a composite table named CREW to link the
CHARTER and EMPLOYEE tables. Some crewmembers, such as flight attendants, may not
be pilots. That’s why the EMPLOYEE table enters into this relationship.)
For use with Database Principles, Second Edition, Cengage Learning EMEA