Figure P1.1 The File Structure For Problems A-F: Database Systems Tutorial 1
Figure P1.1 The File Structure For Problems A-F: Database Systems Tutorial 1
Part I
1. Given the file structure shown in Figure P1.1, answer Problems a through f.
a) How many records does the file contain, and how many fields are there per record?
The file contains seven records and each of the records is composed of five fields.
b) What problem would you encounter if you wanted to produce a listing by city? How would
you solve this problem by altering the file structure?
The city names are contained within the MANAGER_ADDRESS attribute and
decomposing this character (string) field at the application level is unwieldly at best.
If the ability to produce city listings is important, it is best to store the city name as a
separate attribute.
c) If you wanted to produce a listing of the file contents by last name, area code, city, state, or
zip code, how would you alter the file structure?
The more we divide the address into its component parts, the greater its information
capabilities. For example, by dividing MANAGER_ADDRESS into its component
parts (MGR_STREET, MGR_CITY, MGR_STATE, and MGR_ZIP), we gain the
ability to easily select records on the basis of zip codes, city names, and states.
Similarly, by subdividing the MANAGER name into its components
MGR_LASTNAME, MGR_FIRSTNAME, and MGR_INITIAL, we gain the ability
to produce more efficient searches and listings. For example, creating a phone
directory is easy when you can sort by last name, first name, and initial. Finally,
separating the area code and the phone number will yield the ability to efficiently
group data by area codes. Thus MGR_PHONE might be decomposed into
MGR_AREA_CODE and MGR_PHONE. The more you decompose the data into
their component parts, the greater the search flexibility.
d) What data redundancies do you detect, and how could these redundancies lead to anomalies?
The manager named Holly B. Parker occurs three times, indicating that she manages
three projects coded 21-5Z, 25-9T, and 29-2D, respectively and Ms. Parker's phone
number and address also occur three times.
If Ms. Parker moves and/or changes her phone number, these changes must be made
more than once and they must all be made correctly... without missing a single
occurrence. If any occurrence is missed during the change, the data are "different" for
Page 1 of 7
Database Systems Tutorial 1
the same person. After some time, it may become difficult to determine what the
correct data are.
e) Using two relational database tables, PROJECT and MANAGER, eliminate the redundancies
discovered in Problem d. Make sure you use the naming conventions discussed in Section
1.3.3 and connect the two tables through the appropriate link. (Hint: Use Figure 1.11 as an
example.)
f) Create the relational schema to show how the two database tables in Problem e are linked.
Page 2 of 7
Database Systems Tutorial 1
2. Given the file structure shown in Figure P1.7, answer Problems a through g.
a) Identify and discuss the serious data redundancy problems exhibited by the file structure
shown in Figure P1.7.
Given the file's poor structure, the stage is set for multiple anomalies. For
example, if the charge for JOB_CODE = EE changes from $85.00 to $90.00, that
change must be made twice. Also, if employee June H. Sattlemeier is deleted
from the file, you also lose information about the existence of her JOB_CODE =
EE, its hourly charge of $85.00, and the PROJ_HOURS = 17.5. The loss of the
PROJ_HOURS value will ultimately mean that the Coast project costs are not
being charged properly, thus causing a loss of
PROJ_HOURS*JOB_CHG_HOUR = 17.5 x $85.00 = $1,487.50 to the company.
Note that the file contains different JOB_CHG_HOUR values for the same CT
job code, thus illustrating the effect of changes in the hourly charge rate over
time. The file structure appears to represent transactions that charge project hours
to each project. However, the structure of this file makes it difficult to avoid
update anomalies and it is not possible to determine whether a charge change is
accurately reflected in each record. Ideally, a change in the hourly charge rate
would be made in only one place and this change would then be passed on to the
transaction based on the hourly charge. Such a structural change would ensure the
historical accuracy of the transactions.
b) How many different data sources are likely to be used by the file you examined in problem
a?
JOB_CODE, JOB_CHG_HOUR, PROJ__HOURS, EMP_NUM
c) Given your findings in Problems a and b, how would a relational database environment help
eliminate the data redundancy problems?
A good recommendation would be to make the data more atomic.
d) Given your answer to Problem c, how many tables would you use to substantially eliminate
the data redundancy problems? What table structures would you recommend?
Four tables
Entity relationship diagram
Page 3 of 7
Database Systems Tutorial 1
e) Given your answers to problem d, show the table contents for each table.
f) Identify the types of relationships (1:1, 1:M, or M:N) between the tables you defined in
problems d and e.
Page 4 of 7
Database Systems Tutorial 1
Page 5 of 7
Database Systems Tutorial 1
3. Given the table structure shown in Figure P1.14, what problem(s) might you encounter if you
deleted building KOM?
You would lose all the assignment data about teachers Williston, Cordoza, and
Hawkins, as well as the KOM rooms 204E, 123, and 34.
Page 6 of 7
Database Systems Tutorial 1
Part II
1. Each town may be the birthplace of many people. Each person must be born in one and
only one town. (One to Many)
2. Each room may house one or more guest. Each guest may stay in one and only one room.
(One to Many)
3. Each employee must work for one and only one department. Each department may have
one or more employees. (One to Many)
4. Each hotel may be the host of one or more guest. Each guest may be hosted in one or
more Hotels (Many to Many)
5. Each Message must be addressed to one or more persons. Each person may be the
addressee of one or more message. (Many to Many)
6. Each garment must have one and only one price. Each price may be for one or more
garments. (One to Many)
7. Each airline coupon must be used for one and only one destination. Each destination may
be visited with one or more coupons. (One to Many)
8. Each automobile must use one and only one tire size. Each tire size may be used by one
or more automobiles. (One to Many)
9. Each child must have one and only one mother. Each mother must be the parent of one or
more children. (One to Many)
10. Each person must be of one and only one blood type. Each blood type type may classify
one or more persons. (One to Many)
11. A person may be on one or more junk-mail lists. Each junk list may contain one or more
persons. (One to Many)
12. Each student may learn from one or more teachers. Each teacher may educate one or
more students. (Many to Many)
13. Each school may be attended by one or more honor students. Each honor student must
attend one and only one school. (One to Many)
14. Each fingerprint must belong to one and only one person. Each person must have one and
only one fingerprint. (One to One)
Page 7 of 7