CHAPTER 1

advertisement
Chapter One Introduction to Database Processing

 ANSWERS TO GROUP I QUESTIONS
1.1
Why is database processing more important today than ever?
In recent years the explosion of the Internet and the dramatic development of new technology for
the Internet have made knowledge of database technology one of the hottest career paths.
1.2
State the purpose of a database.
The purpose of a database is to help people and organizations keep track of things.
1.3
Summarize problems that can occur when using a list to keep track of some-thing.
Problems occur when changes are made to the list. If multiple copies of data occur in the list, the
change must be made to each copy of the data.
Problems occur when data is delete data. It is possible to delete data about one object in the list and
loose data about a second or third object in the list.
Problems occur when we want to add data to the list. If some data in the list is missing, we may not
know exactly how or where to store the data that we do have.
Lists can also contain inconsistencies. If data is stored twice but the data does not have the same
value, we cannot tell which value is correct. Sometimes what appears to be an inconsistency may
actually be data that represents two different meanings of the data.
When data is missing from a list we cannot tell if the missing data means that the data has no
meaning for a particular row in the list of whether we simply do not know what the value of the
data should be.
Problems also occur when we share data in a list. These problems involve such things as who
determines the format for the list and even the data within the list, who is allowed to modify, delete,
or add items to the list, and who is allowed to see the list.
Problems also occur in lists because lists typically contain data about many different themes.
1.4
Based on your answer to question 1.3, when do you think it is appropriate to use a list to
keep track of something?
A list may be appropriate when the list will contain data about a single theme and the data is not
shared between multiple users that with different objectives for the list.
Use the following list when answering questions 1.5 to 1.9:
Adviser
Jones
KwaiI
Rosenbloom
Rosenbloom
Jones
Adviser Phone
221.2345
223.4444
281.3944
281.3944
221.2345
Student
Parks
Stein Info
Johnson
Gonzales
Rickey
Major
Accounting
Systems
Accounting
Accounting
Accounting
Dept Head
Greene
Masters
Greene
Greene
Greene
1.5 Describe problems that can occur when an adviser changes his or her phone number.
1-1
Chapter One Introduction to Database Processing
Using Jones as an example, if you do not change Jones’ phone number in both the first and last
lines, you cannot tell which phone number is the correct phone number for Jones. In this example,
since the phone numbers would be different, you may not know that the Jones in the last line is the
same Jones as the one in the first line.
1.6
Suppose student Stein drops out of school, and the second row is deleted. Describe the
side effects of this deletion.
The first problem would be that you would loose advisor Kwail phone number. You would also
loose the fact that there is an advisor name Kwail. It also appears that the Dept Head column
contains the name of the department head for the Major. Since Stein is the only Info Systems major,
you would lose the name of the department head for the entire major. (you would also lose the fact
that the school offers an Info Systems major)
1.7
How do we use this list to record the fact that Smith is the department head of the
computer science department?
To record this fact you would need to add a row of data to the list. The row would only contain data
for the Major (Computer Science) and the Dept Head (Smith). Since, at this point, there are no
students that you know of there would be no data for the Student column. Since there is no student
there would also be no Advisor or Advisor Phone.
Even though this can be done to satisfy the requirement not that it may make the list appear to
provide information that is incorrect. For example, it may make someone think that there are really
six students instead of five, we just do not know the name of the sixth student.
1.8
Suppose the entry in the last row, last column is changed from Greene to Abernathy. What
problems will then occur in interpreting this list?
As it currently stands, you should be able to determine that the department head for the Accounting
major is Green. If you make the suggested change, it will appear that the Accounting major has two
different department heads. Would this mean that Greene was the department head when Parks,
Johnson, and Gonzales declared the Accounting major and Abernathy was the department head
when Rickey declared the major? If so, who is the current department head or are there two
department heads? If there is only one department head, which one is the correct department head,
Greene or Abernathy?
1-2
Chapter One Introduction to Database Processing
1.9
Change this list to a set of three interrelated tables. Use the technique shown in Figure 1-4
for representing relationships.
Advisor
ID
1
2
3
4
Advisor
Jones
Kwail
Rosenbloom
Jones
Major
Advisor Phone
221.2345
223.4444
281.3944
221.2345
ID
Major
Dept Head
1 Accounting Greene
2 Info Systems Masters
Student
ID
1
2
3
4
5
Student AdvisorID MajorID
Parks
1
1
Stein
2
2
Johnson
1
3
Gonzales
1
3
Rickey
1
1
1.10 Explain how none of the problems encountered in questions 1.5 to 1.8 can occur with the
tables developed in your answer to question 1.9.
Since Jones is stored in the Advisor table Jones appears only once and can have only one phone
number. If there are two different Jones’, they would both be in the advisor table with different
phone numbers and different Ids. The different Ids would indicate that they are different people.
If Stein drops out of school you would delete Stein’s row in the student table. This deletion would
have no effect on the Advisor table and the major table. No information from these tables would be
lost.
You can add Smith as the department head of the Computer Science major by adding a row to the
Major table. There would be no affect on the Student or Advisor table.
As the table currently stands, the change in question 1.8 would be made in the major table. Since
the Info Systems major exists only once in this table there would be only one change to be made.
Using these tables, the Dept Head column could only represent the current department head.
1.11 Using the SQL statement on page xxx as an example, guess at a similar statement for
joining together the tables in your answer to question 1.9. If any of your column names
have spaces in them, put the column names in brackets [ ]. Because there is no
computation in your result, you will not need an expression like [Daily Rate]*[Days] As
Charge in your answer.
SELECT ADVISOR.Advisor, ADVISOR.[Advisor Phone], STUDENT.Student, MAJOR.Major,
MAJOR.[Dept Head)
FROM ADVISOR, MAJOR, STUDENT
WHERE ADVISOR.ID = STUDENT.AdvisorID
AND STUDENT.MajorID = MAJOR.ID
1.12 Name the four components of a database system.
Figure 1-6 User, Database Application, Database Management System, Database
1-3
Chapter One Introduction to Database Processing
1.13 List the functions of a database application.
• Create and Process Forms
• Create and Transmit Queries
• Create and Process Reports
• Execute Application Logic
• Control Application
1.14 What does DBMS stand for? List the functions of a DBMS.
DBMS stands for Database Management System
The functions of the DBMS are:
• Create Database
• Create Tables
• Create Supporting Structures
• Read Database Data
• Update Database Data
• Maintain Database Structures
• Enforce Rules
• Control Concurrency
• Provide Security
• Perform Backup and Recovery
1.15 Define the term database.
In the most general case, a database is a self-describing collection of related records. For all
relational databases (almost all databases today, and the only type we consider in this book), we can
modify this definition to say a database is a self-describing collection of related tables.
1.16 List the contents of a database.
• User Data
• Metadata
• Indexes and Related Structures
• Stored Procedures
• Triggers
• Application Metadata
1.17 What is metadata? Give an example.
Data about the structure of a database is called metadata. Examples of metadata are the names of
tables, the names of columns and the tables to which they belong; properties of tables and columns;
and so forth.
1.18 What is the difference between a stored procedure and a trigger?
A stored procedure is a program that is stored within the database. Some stored procedures are
utility programs for the database.
A trigger is a procedure that is executed when a particular data activity occurs.
1.19 Explain the differences between personal, workgroup, and organizational databases.
1-4
Chapter One Introduction to Database Processing
Personal: Mary Richards Housepainting: single-user databases with a relatively small amount of
data—say, fewer than 10 megabytes. The forms and reports for these databases are generally simple
and straightforward.
Workgroup: Treble Clef Music; they have more than one user, but usually fewer than 20 or 30
users altogether. They contain a moderate amount of data—say, 50 or 100 megabytes. The forms
and reports need to be complex enough to support several different business functions.
Organizational: The largest databases are like those in the auto registration case, which have
hundreds of users and trillions of bytes of data. Many different applications are in use, with each
application having its own forms and reports. The characteristics of these types of databases are
summarized in Figure 1-16.
1.20 Summarize the tasks in the requirements phase of the development on a database
system.
The tasks to be completed in the requirements phase of the development of a database are to:
Build data model
Specify data items
Define constraints and rules
Determine application requirements
1.21 What is a data model? Why are such models important?
A data model is a logical representation of the structure of the database. Data modeling is very
important because the design of the database and all of its structures depend on the data model. If
the data model is incorrect, the result will be waste, aggravation, delays, and frustration.
1.22 Summarize the tasks in the design phase of the development on a database system.
In the design phase of the development of a database you must design the:
Tables
Relationships
Indexes
Constraints
Stored procedures and triggers
Forms
Reports
Queries
Application code
1.23 Summarize the tasks in the implementation phase of the development on a database
system.
In the implementation phase of the development of a database you must:
Create tables
Create relationships
Create constraints
Write stored procedures and triggers
Fill the database
Create forms
Create reports
Create queries
Write application code
1-5
Chapter One Introduction to Database Processing
Test
1.24 Name two data models that preceded the relational model.
IBM developed and promoted DL/I, or Data Language One, which modeled database data in the
form of hierarchies or trees.
CODASYL, the group that developed the standards for the COBOL language, created a model in
the 1970s called the DBTG (Data Base Task Group) Model. The DBTG model could readily
represent both hierarchies and networks. This model was at one time proposed as a national
standard, but was never adopted primarily because of its complexity.
1.25 Describe the disadvantages of the two data models in your answer to question.
The DL/1 model was not truly general-purpose. Representing non-hierarchical network
data was cumbersome.
The CODASYL model’s primary disadvantage was its complexity.
1.26 Who first proposed the relational model?
E.F. Codd proposed the relational model in 1970. Codd worked for IBM and after 10 years of
research, development, and corporate lobbying, he and others convinced IBM to develop DBMS
products based on the relational model.
1.27 How did personal DBMS products influence the development of organizational DBMS
products?
Because there was plenty of computing power available on personal computers, personal DBMS
products were able to create more graphical user interfaces. Over time, the influence of these
products changed the interfaces of larger organizational DBMS products as well.
1.28 Name three early personal DBMS products.
Three early personal DBMS products were dBase, a product marketed by the Ashton-Tate
Corporation, R:base from the Microrim Corporation, and Paradox from Borland.
1.29 What is the purpose of an OODBMS?
The goal of OODBMS products was to be able to store object-oriented programming objects (such
as those in C++ or Java) in a database without having to transform them into relational format.
1.30 Why have OODBMS not been commercially successful?
Their use requires organizations to transform their databases from relational to OODBMS format.
Also, most large organizations have older applications that are not based on object-oriented
programming. Somehow, the programs in these applications would need to be accommodated by
the new OODBMS. Thus, the high cost of migrating existing databases and information systems
from relational DBMS to OODMBS has prohibited their wide use.
1.31 What is an object-relational DBMS?
Object-relational DBMS products, such as Oracle 8i and 9i, have been developed that allow both
relational and object views of data on the same database.
1.32 What technology is at the leading edge of the database field today?
1-6
Chapter One Introduction to Database Processing
Recent years have seen the introduction and use of XML, which is a technology that originated to
support Web sites, but has since been extended to provide important solutions to database
problems. The integration of database technology and XML is the leading edge of the database field
today and will be important for many years in the future.

ANSWERS TO GROUP II QUESTIONS
1.33 Suppose that the New Orleans Wooden Boat Society (a fictitious organization) publishes a
monthly newsletter for which it charges $35 per year. Assume they keep the following data
in the form of list in a spreadsheet:
Name, Street, ApartmentNo, City, State, Zip, StartDate, EndDate, AmountPaid
What problems are likely to occur when maintaining this data as a list?
Suppose a library wanted to purchase 3 subscriptions to the newsletter. You would need to make
three different entries for the library to know that three copies must be sent and that the library paid
$35 for each subscription. If you simply made one entry for $105 being the AmountPaid, you may
not know that three copies of the newsletter must be mailed. If this were the only library in the list
you may think that a subscription cost $105 when purchased by a library but everyone else only
pays 35. If three entries were made and the Street name was changed, all three entries must be
changed.
1.34 Suppose that a subscriber who has received the newsletter for three years changes his or
her address. Should the address data be changed on all subscriptions, or on only the
current subscription? Why or why not?
The answer here would depend upon how the data were being used. If the data were simply being
used as historical data to know where subscriptions were sent, the answer would be NO, you would
want to keep the original mailing address. If you did not change the address and wanted to send a
reminder to any address that had not renewed their subscription you may send a reminder to
someone that has moved into your old address but never ordered the subscription. You would
probably need to argue that the address should be changed in this case.
1.35 Break the list in question 1.33 into two tables, one for SUBSCRIBER and one for
SUBSCRIPTION. Relate the tables using Figure 1-4 as an example. How does this
arrangement fix the problems you identified in question 1.33? How does this arrangement
affect your answer to question 1.34? Make an argument that this two-table design is not
an improvement over the spreadsheet, and is thus unnecessary.
1-7
Chapter One Introduction to Database Processing
Subscription
Id StartDate
EndDate
AmountPaid
1 1/1/2003 12/31/2003
2 2/1/2003 1/31/2004
3 2/1/2003 1/31/2004
4 2/1/2003 1/31/2004
5 3/20/2002 2/19/2003
6 3/20/2003 2/19/2004
$35.00
$35.00
$35.00
$35.00
$35.00
$35.00
SubscriberID
1
2
2
2
3
3
Subscriber
ID
Name
1 J.J. Jones
2 Lincoln Library
3 B.B. Baker
Street
City
State
Zip
105 Main St. Fairfax VA
08791
25 Market St. Edmond OK
46731
1002 East Rd. Nelson SC
56789
Since each subscriber exits only once in the subscriber table a subscriber can only have one
address, thus the question is mute since there are no additional addresses to change.
It is difficult to argue that this is not an improvement. It saves space (the address is not duplicated)
and allows each table to carry a single theme (either theme subscriber or theme subscription). By
changing the design you have made changes to what the data must mean. The address must be the
current address. This design does not provide an opportunity store previous addresses.
1.36 Suppose that the society decides to have two publications: a shop guide that is published
quarterly (Winter, Spring, Summer, Fall), and the newsletter that is published monthly.
Assume that the cost of the shop guide is $15 per year, and the cost of the newsletter is
$35 per year. Assume that the society keeps the following data:
Name, Street, ApartmentNo, City, State, Zip, Publication, StartDate, EndDate, AmountPaid
What problems are likely to occur when maintaining this data as a list?
All the original problems would still exist. In addition, if the list were used to provide other
advertising, subscriber that had two current subscriptions would get two advertisements. If a
subscriber that subscribed to both publications moved they would need to notify you twice to make
sure the current address were changed in both places. In essence, anyone that that subscribed to
both publications would need to be treated as two different people.
1.37 Break the list in question 1.36 into two tables: one for SUBSCRIBER and one for
SUBSCRIPTION. Relate the tables using Figure 1-4 as an example. How does this
arrangement fix the problems you identified in question 1.36? Explain why it is easier to
make the argument that this two-table design is an improvement over the spreadsheet.
1-8
Chapter One Introduction to Database Processing
Subscription
Id Publication
1 Newsletter
2 Shop Guide
3 Newsletter
4 Newsletter
5 Newsletter
6 Shop Guide
StartDate
1/1/2003
1/1/2003
2/15/2003
2/15/2003
2/1/2003
2/1/2003
EndDate AmountPaid SubscriberID
12/31/2003
$35.00
1
12/31/2003
$15.00
1
2/14/2004
$35.00
2
2/14/2004
$35.00
2
1/31/2004
$35.00
3
1/31/2004
$15.00
3
Subscriber
ID Name
Street
City State
1 J.J. Jones 105 Main St. Fairfax VA
2 T.T. Turner 25 Market St. Edmond OK
3 B.B. Baker 1002 East Rd. Nelson SC
Zip
08791
46731
56789
This design continues to eliminate the need for duplicate addresses. If a subscriber changed
addresses they would need to notify you only once since they only have one address. Each
subscriber is now treated as one person and not two different people.
1.38 Suppose that the cost of the shop guide is $15 per year, and the cost of the newsletter is
$35 per year, but the cost of both is $40 per year. Does this situation affect the design of
your tables for question 1.37? Why or why not? How should the society handle this
situation?
This change would affect the design of the tables. You would need to create a new publication
(probably called Both) with an AmountPaid of $40. The society would handle this by using a
subscription table like the one below.
Subscription
Id SubscriptionType
1 Both
2 Newsletter
3 Newsletter
4 Both
5 Shop Guide
StartDate
1/1/2003
2/15/2003
2/15/2003
2/1/2003
3/1/2003
EndDate AmountPaid SubscriberID
12/31/2003
$40.00
1
2/14/2004
$35.00
2
2/14/2004
$35.00
2
1/31/2004
$40.00
3
2/29/2004
$15.00
4
1.39 Just about anyone with computer skills in the society can create and process a list in a
spreadsheet. Developing a database and database application, however, requires
specialized knowledge and skills. If the society asked you to help them determine whether
the cost and trouble of a database were worthwhile, how would you proceed? What
questions would you ask? What sort of an analysis would you do?
You should begin by creating a data model for the problem. To do this you would need expertise in
data modeling (Chapters 2-5). Once the model were created you could compare the database model
1-9
Chapter One Introduction to Database Processing
to the model of the list. Specify the data items and define the constraints and business rules. Once
you have done this you could see many of the advantages of the database model over the list model.
You should also ask questions like how many users would be using the list. If there are several
users there would be even more reason to justify the database. Also ask about standards between
users. Make sure all users can agree on certain standards such as the format for Dates. Ask about
privacy issues. Are some users allowed to see the address and other not allowed to see the
addresses.

ANSWERS TO FIREDUP PROJECT QUESTIONS
FiredUp, Inc., is a small business owned by Curt and Julie Robards. Based in Brisbane,
Australia, FiredUp manufactures and sells a lightweight camping stove called the FiredNow.
Curt, who previously worked as an aerospace engineer, invented a patented burning nozzle that
enables the stove to stay lit in very high winds—up to 90 miles per hour. Julie, an industrial
designer by training, developed an elegant folding design that is small, lightweight, easy to set
up, and very stable. The Robards manufacture the stove in their garage, and they sell it directly
to their customers over the Internet, via fax, and via postal mail.
The owners of FiredUp need to keep track of the stoves they have sold, in case they should
ever need to contact their users regarding product failures or other product-liability matters.
Accordingly, they include a product registration form with each of their stoves. The form
contains the following data:
PurchaserName, StreetAddress, ApartmentNumber, City, State/Province, Zip/PostalCode,
Country, EmailAddress, PhoneNumber, DateOfPurchase, SerialNumber
A.
Assume that FiredUp stores this data as a list in a spreadsheet. Describe five potential
problems they can have when storing the data in this manner.
1. Each time a user purchases a stove they are entered into the list. If a user purchased five
stoves they would be considered five different users.
2. If a user moved and had purchased more than one stove, the address would need to be
updated for each stove purchased.
3. Email addresses constantly change and in this design a user has the opportunity to have many
different e-mail addresses, one for each purchase. The likelihood of these addresses becoming
obsolete quickly is very high, especially since the user can have many addresses.
4. The same problem occurs with the phone number
5. If the Robards decide to create a catalog and send it to their past customers, the odds of a
customer getting two or three catalogues is very high, thus increasing the cost of the mailing.
B.
Assume that instead of a spreadsheet, they decide to create a personal database with the
following tables:
CUSTOMER (Name, StreetAddress, ApartmentNumber, City, State/Province,
Zip/PostalCode, Country, EmailAddress, PhoneNumber)
and
PURCHASE (DateOfPurchase, SerialNumber)
1.
Construct a table of sample data that conforms to the CUSTOMER structure. Include at
least four rows in your table. For this question and the following questions, just list the data
using a word processor.
1-10
Chapter One Introduction to Database Processing
CUSTOMER
Name
StreetAddr
A.A. Able
103 East Ave.
B.B. Baker
234 Main St.
C.C. Clark
23 Maple La.
Apt
St
23-B London
D.D. O'Donald 23 Shamrock Rd. A3
2.
City
Postal
Country
EmailAddress
Phone
00957
ENG
Ableaa@aol.com
780.056.9043
Edmond OK
55671
USA
Winwiz@msn.com
567.321.7654
Edmond OK
55671
USA
Checker@Hotmail.com 567.321.8902
O'Bryrne
00346
IRE
Nimble@uoi.edu
987.7654.321
Which of the columns of the CUSTOMER table can be used as a key (a column that
identifies to identify a unique row of the table)?
In the table above, either Name, Street, Phone or EmailAddress could be used as the Key since any
one uniquely identifies a row. You must realize that in the real world, none of these will satisfy the
requirements for a Key. Name and address will not remain unique very long. There are many B.B.
Bakers in the world and almost every city has a 234 Main St. EmailAddress and Phone Number are
the best candidates for a key but phone number change too often (especially with the use of cell
phones) to be considered a good candidate for a key. Email Addresses also change too often to be
considered a good key. A key should rarely change.
3.
Construct a table of data that conforms to the PURCHASE structure. Include at least four
rows in your table.
Purchase
4.
DateOfPurchase
SerialNumber
2/12/2003
12001
2/19/2003
12002
2/19/2003
12003
2/21/2003
12004
Which of the columns of the PURCHASE table can be used as a key of PURCHASE?
The serial number can be used as the Key as long as all stoves have a serial numbers.
5.
Using the tables defined previously, there is no way to relate a particular customer to his
or her stove. One way to do that is to add SerialNumber of PURCHASE to CUSTOMER.
The CUSTOMER table then appears as follows:
CUSTOMER (Name, StreetAddress, ApartmentNumber, City, State/Province, Zip/PostalCode, Country,
EmailAddress, PhoneNumber, SerialNumber)
Copy your sample CUSTOMER data and add the SerialNumber column to it. Call this new
table CUSTOMER1
CUSTOMER1
Name
Phone
StreetAddr
Apt
City
A.A. Able
780.056.9043 103 East Ave.
B.B. Baker
567.321.7654 234 Main St.
Edmond
C.C. Clark
567.321.8902 23 Maple La.
Edmond
St
23-B London
1-11
Postal Country
EmailAddress
SerialNumber
00957
ENG
Ableaa@aol.com
12001
OK
55671
USA
Winwiz@msn.com
12002
OK
55671
USA
Checker@Hotmail.com
12003
Chapter One Introduction to Database Processing
CUSTOMER1
Name
Phone
StreetAddr
Apt
D.D. O'Donald 987.7654.321 23 Shamrock Rd. A3
6.
City
O'Bryrne
St
Postal Country
00346
IRE
EmailAddress
Nimble@uoi.edu
SerialNumber
12004
An alternative technique for representing the relationship of the two tables is to place
EmailAddress of CUSTOMER in PURCHASE. The PURCHASE table then appears as
follows:
PURCHASE (DateOfPurchase, SerialNumber, EmailAddress)
Purchase1
DateOfPurchase
2/12/2003
2/19/2003
2/19/2003
2/21/2003
7.
SerialNumber
12001
12002
12003
12004
EmailAddress
Ableaa@aol.com
Winwiz@msn.com
Checker@Hotmail.com
Nimble@uoi.edu
You now have three possible database structures:
DB1: CUSTOMER1 with PURCHASE
DB2: CUSTOMER with PURCHASE1
DB3: CUSTOMER1 with PURCHASE1
a. Under what circumstances would you recommend the structure in DB1?
This structure only allows a customer to purchase one stove. Use this structure if a Customer is
not allowed to purchase more than one stove.
b. Under what circumstances would you recommend the structure in DB2?
This is the better of the three structures. It allows a Customer to have more than one Purchase.
This structure also guarantees that a particular Stove cannot be registered by more than one
person. Use this structure when a Customer may have more than one Purchase.
c. Under what circumstances would you recommend the structure in DB3?
The DB3 structure suffers from the same shortcoming as the DB1 structure. In the Customer
table a customer can only have one Purchase represented in the Customer table. You could use
this structure if you wanted to relate a Customer to their last purchase. The Purchase table will
still allow a Customer to have more than one purchase.

ANSWERS TO TWIGS TREE TRIMMING SERVICE
Samantha Green owns and operates Twigs Tree Trimming Service. Samantha graduated from
the forestry program and worked for a large landscape design firm that performs tree trimming
and removal. After several years of experience, she bought her own truck, stump grinder, and
other equipment and then opened her own business in St. Louis, Missouri.
Although many of her jobs are one-time operations to remove a tree or stump, others are
recurring: trimming a tree or groups of trees every year or every other year. When business is
slow, she calls former clients to remind them of her service and of the need to trim their trees on
a regular basis.
1-12
Chapter One Introduction to Database Processing
Samantha keeps the following data about each of her jobs:
OwnerName, Phone, Street Address, City, State, Zip, DateOfService, Description,
AmountBilled, AmountPaid, DateOfPayment.
A. Assume that Samantha stores this data as a list in a spreadsheet. Describe five potential
problems Samantha can have when storing the data in this manner.
1. Phone, address, city, state, zip will be duplicated. When a customer’s phone number changes, it
must be updated in each place.
2. When a customer moves to a new address, the address must be change in each place it occurs in
the list.
3. Each entry in the table is treated as a separated customer. When a mailing is created a customer
may get several copies of the mailing if they appear in the list more than once.
4. What happens when a customer moves to a new address and someone else moves into the old
customer’s address. The new customer also becomes a customer. It may appear that we have two
customers at the same address. Who do we bill?
5. The table carries two themes, one about customer and one about service.
B. Assume that instead of a spreadsheet, Samantha decides to create a personal database
with the following tables:
CUSTOMER (OwnerName, Phone, Street Address, City, State, Zip)
and
SERVICE (DateOfService, Description, AmountBilled, AmountPaid, DateOfPayment)
1. Construct a table of sample data that conforms to the CUSTOMER structure. Include at
least four rows in your table. For this question and the following questions, just list the
data using a word processor.
CUSTOMER
OwnerName
A. A. Able
B.B. Baker
C. C. Cline
D. D. Daniel
Phone
540.433.2200
540.566.1122
703.777.2021
540.433.5572
Street Address
109 Main St.
1340 Market Ave.
1002 Broad St.
12 Maple Ave.
City
Fairfax
Springfield
Baltimore
Fairfax
State
VA
VA
MD
VA
Zip
66702
66732
70344
66702
2. Which of the columns of the CUSTOMER table can be used as a key (a column that
identifies to identify a unique row of the table)?
The best key would be Phone or the combinations of Street, City, and State.
3. Construct a table of data that conforms to the SERVICE structure. Include at least four
rows in your table.
SERVICE
DateOfService
5/10/2003
5/10/2003
5/12/2003
5/14/2003
Description
Trim Shrubs
Trim Shrubs
Mow Lawn
Mulch Shrubs
AmountBilled
$75.00
$75.00
$35.00
$125.00
AmountPaid
$75.00
$75.00
$35.00
$50.00
DateOfPayment
5/30/2003
5/30/2003
6/1/2003
6/30/2003
4. Explain why none of the columns in the SERVICE table can be used as a key.
1-13
Chapter One Introduction to Database Processing
Look at the first two rows of data. These are two different services performed for different people
on the same day. Both rows contain the same data so there is not column that that makes the rows
unique.
5. Add an ID column to SERVICE similar to that for the tables in Figure 1-4. Modify your
example data to include the ID column.
SERVICE
ID
1
2
3
4
DateOfService
5/10/2003
5/10/2003
5/12/2003
5/14/2003
Description
Trim Shrubs
Trim Shrubs
Mow Lawn
Mulch
Shrubs
AmountBilled
$75.00
$75.00
$35.00
$125.00
AmountPaid
$75.00
$75.00
$35.00
$50.00
DateOfPayment
5/30/2003
5/30/2003
6/1/2003
6/30/2003
6. Using the tables defined previously, there is no way to relate a particular customer to his
or her service. One way to do that is to add ID of SERVICE to CUSTOMER. The
CUSTOMER table then appears as follows:
CUSTOMER (OwnerName, Phone, Street Address, City, State, Zip, ServiceID)
Copy your sample CUSTOMER data, and add the ServiceID column to it. Call this new
table CUSTOMER1.
CUSTOMER1
OwnerName
A. A. Able
B.B. Baker
C. C. Cline
D. D. Daniel
Phone
540.433.2200
540.566.1122
703.777.2021
540.433.5572
Street Address
109 Main St.
1340 Market Ave.
1002 Broad St.
12 Maple Ave.
City
Fairfax
Springfield
Baltimore
Fairfax
State
VA
VA
MD
VA
Zip
66702
66732
70344
66702
ServiceID
1
2
3
4
7. An alternative technique for representing the relationship of the two tables is to place
Phone of CUSTOMER in SERVICE. The SERVICE table then appears as follows:
SERVICE (DateOfService, Description, AmountBilled, AmountPaid, DateOfPayment,
Phone)
Copy your sample SERVICE data, and add the Phone column to it. Call this new table
SERVICE1.
SERVICE1
ID
1
2
3
4
DateOfService
5/10/2003
5/10/2003
5/12/2003
5/14/2003
Description
Trim Shrubs
Trim Shrubs
Mow Lawn
Mulch
Shrubs
AmountBilled
$75.00
$75.00
$35.00
$125.00
AmountPaid
$75.00
$75.00
$35.00
$50.00
DateOfPayment
5/30/2003
5/30/2003
6/1/2003
6/30/2003
8. You now have three possible database structures:
DB1: CUSTOMER1 with SERVICE
DB2: CUSTOMER with SERVICE1 and
DB3: CUSTOMER1 with SERVICE1
a. Under what circumstances would you recommend the structure in DB1?
1-14
Phone
540.433.2200
540.566.1122
703.777.2021
540.433.5572
Chapter One Introduction to Database Processing
I would recommend this structure if a customer were allowed to have only one service. This
structure does not allow a customer to have multiple services.
b. Under what circumstances would you recommend the structure in DB2?
I would recommend this structure when a customer may have many services. Since the
service is performed for a single customer, the customer’s phone number can serve to relate
each service to a customer.
c. Under what circumstances would you recommend the structure in DB3?
I would recommend this structure if a customer were allowed to have only one service or if it
were common to find a customer’s last service. Note that the Customer can have only one
ServiceID so this ServiceID would need to the last service for the customer.
1-15
Download