Professional Documents
Culture Documents
Concepts of Database Management 8th Edition Pratt Solutions Manual Download
Concepts of Database Management 8th Edition Pratt Solutions Manual Download
Solution Manual:
https://testbankpack.com/p/solution-manual-for-concepts-of-database-management-8th-
edition-by-pratt-last-isbn-1285427106-9781285427102/
Test bank:
https://testbankpack.com/p/test-bank-for-concepts-of-database-management-8th-edition-
by-pratt-last-isbn-1285427106-9781285427102/
Chapter 4
The Relational Model 3: Advanced Topics
Solutions
Answers to Review Questions
Note: Answers to odd-numbered review questions are found in Appendix D of the textbook.
1. A view is an individual user’s picture of the database. It is defined using a defining query. The data in the view
never actually exists in the form described in the view. Rather, when a user accesses the view, his or her query is
merged with the defining query of the view to form a query that pertains to the whole database.
2. a.
CREATE VIEW TopLevelCust AS
SELECT CustomerNum, CustomerName, Street, City, State, PostalCode, Balance,
CreditLimit
FROM Customer
WHERE CreditLimit >= 10000;
b.
SELECT CustomerNum, CustomerName
FROM TopLevelCust
WHERE Balance > CreditLimit;
c.
SELECT CustomerNum, CustomerName
FROM Customer
WHERE CreditLimit >= 10000
AND Balance > CreditLimit;
3. a.
CREATE VIEW ItemOrder AS
©2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted
in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Concepts of Database Management, Eighth Edition Solutions 4-2
©2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted
in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Concepts of Database Management, Eighth Edition Solutions 4-3
key cannot exist without being related to a row in the other table. Legal-values integrity applies to fields in which
there is a specific set of allowable values, called legal values. The field must contain one of the legal values. Legal-
values integrity ensures that fields will not contain invalid data.
13. Adding an order to the Orders table on which the customer number does not match a customer number in the
Customer table would violate referential integrity. In addition, changing the customer number on a record in the
Orders table to a number that does not match a customer number in the Customer table would also violate referential
integrity. If deletes do not cascade, deleting a customer that has orders would violate referential integrity. If deletes
cascade, such a customer can be deleted, in which case all orders for that customer will automatically be deleted.
14. You can change the structure of a table in SQL using the ALTER TABLE command. You can add columns
(ALTER TABLE table-name ADD column-name); delete columns (ALTER TABLE table-name DELETE column-
name); and change columns (ALTER TABLE table-name CHANGE column-name TO new description). You can
also delete tables (DROP TABLE table-name).
15. Stored procedures are special files containing a collection of SQL statements that will be executed frequently. The
statements in a stored procedure are compiled and optimized, enabling the stored procedure to execute as efficiently
and as rapidly as possible. It also makes the execution of the commands in the stored procedure simpler than if the
user had to type the command each time he or she wanted to use it.
16. A trigger is an action that occurs automatically in response to an associated database operation. Triggers assist in
providing data integrity. In Access 2013, you can gain the functionality of a trigger by creating and using data
macros.
17. [Critical Thinking] Answers will vary but students should justify their decisions. MemberLastName is an obvious
choice for a single-field index because you need to update records and search on last name. The combination of
MemberLastName and MemberFirstName is an obvious choice for a multiple-field index for searching purposes. If
the company does targeted mailings, then the combination of State and Postal Code would be an appropriate index.
18. [Critical Thinking] Yes, Toys Galore would be included in the query result. The query results are based on the
current data in the Customer table. The view does not include data, only the defining query. If you update the credit
limit in the Customer table to $10,000 then it will meet the criteria for the query and be retrieved.
1. SQL:
CREATE VIEW TopLevelCust AS
SELECT CustomerNum, CustomerName, Street, City, State, PostalCode, Balance,
CreditLimit
FROM Customer
WHERE CreditLimit >= 10000;
SELECT *
FROM TopLevelCust;
Access:
Create a query containing the CustomerNum, CustomerName, Street, City, State, PostalCode, Balance, and
CreditLimit fields. Enter >=10000 as the criterion for the CreditLimit field. Save the query as TopLevelCust. Run
the query.
2. SQL:
©2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted
in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Concepts of Database Management, Eighth Edition Solutions 4-4
SELECT *
FROM ItemOrder;
Access:
Create a query containing the ItemNum, Description, and Price fields from the Item table as well as the OrderNum,
OrderDate, NumOrdered, and QuotedPrice fields from the OrderLine table. Save the query as ItemOrder. Run the
query.
3. SQL:
CREATE VIEW OrdTot AS
SELECT OrderNum, SUM(NumOrdered * QuotedPrice)
FROM OrderLine
GROUP BY OrderNum;
SELECT *
FROM OrdTot;
Access:
Create a query containing the OrderNum field from the OrderLine table. Add a computed field in which the
calculation is NumOrdered * QuotedPrice. Add the Totals row. Make sure the entry in the Totals row for the
OrderNum field is GroupBy and select Sum as the entry in the Totals row for the computed field. Save the query as
OrdTot. Run the query.
4. SQL:
a.
CREATE INDEX ItemIndex1 ON OrderLine (ItemNum);
b.
CREATE INDEX ItemIndex2 ON Item (Storehouse);
c.
CREATE INDEX ItemIndex3 ON Item (Storehouse, Category);
d.
CREATE INDEX ItemIndex4 ON Item (Storehouse, OnHand DESC);
Access:
a. While viewing the OrderLine table in Design view, select Yes (Duplicates OK) for the Indexed property for
the ItemNum field.
b. While viewing the Item table in Design view, select Yes (Duplicates OK) for the Indexed property for the
Storehouse field.
c. While viewing the Item table in Design view, click the Indexes button in the Show/Hide group on the
TABLE TOOLS DESIGN tab, enter ItemIndex3 as the name of the index, and then select the Storehouse and
Category fields.
d. While viewing the Item table in Design view, click the Indexes button in the Show/Hide group on the
TABLE TOOLS DESIGN tab, enter ItemIndex3 as the name of the index, and then select the Storehouse and
OnHand fields. Select Descending as the sort order for the OnHand field.
5. SQL:
DROP INDEX ItemIndex3;
Access:
©2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted
in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Concepts of Database Management, Eighth Edition Solutions 4-5
While viewing the Item table in Design view, click the Indexes button in the Show/Hide group, and then delete the
ItemIndex3 index.
6. SQL:
For the Item table:
CHECK (Category IN ('PZL', 'GME', 'TOY'))
PRIMARY KEY (ItemNum)
For the OrderLine table:
FOREIGN KEY (ItemNum) REFERENCES Item
Access:
While viewing the Item table in Design view, select the Category field and enter the following as a validation rule:
=PZL or =GME or =TOY. Select the ItemNum field and click the Primary Key button in the Tools group on the
TABLE TOOLS DESIGN tab. Select the DATABASE TOOLS tab and then select the Relationships button in the
Relationships group. Create a relationship between the Item and OrderLine tables on the ItemNum fields and select
the option to enforce referential integrity.
7. SQL:
ALTER TABLE Item
ADD Allocation DECIMAL (4,0);
UPDATE Item
SET Allocation=0;
SELECT SUM(NumOrdered)
FROM OrderLine
WHERE ItemNum = 'KD34';
UPDATE Item
SET Allocation = (answer to previous query)
WHERE ItemNum = 'KD34';
SELECT *
FROM Item;
Access:
While viewing the Item table in Design view, add a new field named Allocation with the Number data type. Create
and run an Update query to change the value of the Allocation field for each record to 0. Create and run a query to
calculate the total of the NumOrdered field on each record in the OrderLine table on which the Item number is
KD34. While viewing the Item table in Datasheet view, select the record on which the Item number is KD34. Select
the Allocation field and change the value to the answer from the query.
8. SQL:
ALTER TABLE Item
CHANGE COLUMN Storehouse TO CHAR (2);
UPDATE Item
SET Storehouse=′1a′
WHERE Storehouse=′1′;
SELECT *
FROM Item;
Access:
While viewing the Item table in Design view, select the Storehouse field, and then change the Field Size property to
2. Create and run an Update query to find all records where the Storehouse value is 1 and change the value of the
Storehouse field on these records to 1a. Run a Select query that selects all records from the Item table.
9. SQL:
ALTER TABLE Item
DELETE Allocation;
Access:
View the Allocation field in Design view, and then delete the row for the Allocation field.
©2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted
in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Concepts of Database Management, Eighth Edition Solutions 4-6
10. SQL:
DROP TABLE Item;
Access:
Right-click the Item table in the Navigation Pane, and then click Delete on the shortcut menu.
©2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted
in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Concepts of Database Management, Eighth Edition Solutions 4-7
12. [Critical Thinking] Employee received the error message because referential integrity exists between the OrderLine
table and the Item table. To allow the deletion of records from the Item table, you need to cascade the delete. In Access,
select the Cascade Delete Related Records check box in the Edit Relationships dialog box.
13. [Critical Thinking] No changes are needed if legal-values integrity has not been specified for the Category field in
the Item table. If the Item table includes only the allowable values, TOY, GME, and PZL for the Category field then you
must modify the table design first by adding the allowable value, CRV to the Category field. To do this in Access, while
viewing the Item table in Design view, select the Category field and modify the validation rule as follows: =PZL or =GME or
=TOY or =CRV. In SQL, do the following:
ALTER TABLE Item
CHECK (Category IN ('PZL', 'GME', 'TOY',’CRV’))
1. SQL:
CREATE VIEW NHTrips AS
SELECT TripID, TripName, StartLocation, Distance, MaxGrpSize, Type, Season
FROM Trip
WHERE State = ‘NH’;
SELECT *
FROM NHTrips;
Access:
Create a query containing the TripID, TripName, StartLocation, Distance, MaxGrpSize, Type, Season, and State
fields from the Trip table. Remove the check mark from the Show check box in the State column and enter NH as
the criterion in the State column. Save the query as NHTrips. Run the query.
2. SQL:
CREATE VIEW Hiking AS
SELECT TripID, TripName, StartLocation, State, Distance, MaxGrpSize,
Season
©2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted
in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Concepts of Database Management, Eighth Edition Solutions 4-8
FROM Trip
WHERE Type = 'Hiking';
SELECT *
FROM Hiking;
Access:
Create a query containing the TripID, TripName, StartLocation, State, Distance, MaxGrpSize, Season, and Type
fields from the Trip table. Remove the check mark from the Show check box in the Type column and enter Hiking
as the criterion in the Type column. Save the query as Hiking. Run the query.
3. SQL:
CREATE VIEW ReservationCustomer AS
SELECT Reservation.ReservationID, Reservation.TripID, TripDate,
Reservation.CustomerNum, LastName, FirstName, Phone
FROM Reservation, Customer
WHERE Reservation.CustomerNum = Customer.CustomerNum
SELECT *
FROM ReservationCustomer;
Access:
Create a query containing the ReservationID, TripID, TripDate, and CustomerNum fields from the Reservation table
and the LastName and FirstName fields from the Customer table. Save the query as ReservationCustomer. Run the
saved query.
4. SQL:
a.
CREATE INDEX TripIndex1 ON Trip (TripName);
b.
CREATE INDEX TripIndex2 ON Trip (Type);
c.
CREATE INDEX TripIndex3 ON Trip (Type, Season DESC);
Access:
a. While viewing the Trip table in Design view, select Yes (Duplicates OK) for the Indexed property for the
TripName field.
b. While viewing the Trip table in Design view, select Yes (Duplicates OK) for the Indexed property for the
Type field.
c. While viewing the Trip table in Design view, click the Indexes button in the Show/Hide group on the
DESIGN tab, enter TripIndex3 as the name of the index, and then select the Type and Season fields. Select
Descending as the sort order for the Season field.
5. SQL:
DROP INDEX TripIndex3;
Access:
While viewing the Trip table in Design view, click the Indexes button in the Show/Hide group on the DESIGN tab,
and then delete the TripIndex3 index.
6. SQL:
CHECK (Distance >= 4)
Access:
While viewing the Trip table in Design view, change the Validation Rule property for the Distance field to >=4.
7. SQL:
For Reservation table:
FOREIGN KEY (CustomerNum) REFERENCES Customer
©2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted
in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Concepts of Database Management, Eighth Edition Solutions 4-9
12a. Open the Customer table in Design view and add the PreviousTrip field with a number data type. Create a Totals
query on the Reservations table, group the records by customer number, and count the number of reservations. Open the
Customer table in Datasheet view and update the table with these values, assigning the values 0 to customers 110 and 123.
©2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted
in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Concepts of Database Management, Eighth Edition Solutions 4-10
13. [Critical Thinking] There is a relationship between the TripGuides table and the Trip and Guide tables. The TripID
field in the TripGuides table is a foreign key that references the Trip table. The GuideNum field in the TripGuides table is a
foreign key that references the Guide table.
14. [Critical Thinking] Answers will vary. You could add integrity constraints to both the Type and State tables
specifying allowable values for the Type field as Hiking, Biking, and Paddling. You could specify allowable values for the
State field with allowable values for the New England states. You also could specify a maximum group size limit.
©2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted
in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Concepts of Database Management, Eighth Edition Solutions 4-11
1. SQL:
CREATE VIEW LargeCondo AS
SELECT CondoID, LocationNum, UnitNum, CondoFee, OwnerNum
FROM CondoUnit
WHERE SqrFt > 1200;
SELECT *
FROM LargeCondo;
Access:
Create a query containing the CondoID, LocationNum, UnitNum, CondoFee, OwnerNum, and SqrFt fields from the
CondoUnit table. Remove the check mark from the Show check box for the SqrFt column and enter >1200 as the
criterion in the SqrFt column. Save the query as LargeCondo. Run the query.
2. SQL:
CREATE VIEW InitialService AS
SELECT CondoID, CategoryNum, Description, EstHours
FROM ServiceRequest
WHERE SpentHours = 0;
SELECT *
FROM InitialService;
Access:
Create a query containing the CondoID, CategoryNum, Description, EstHours, and SpentHours fields from the
ServiceRequest table. Remove the check mark from the Show check box for the SpentHours column and enter 0 as
the criterion in the SpentHours column. Save the query as InitialService. Run the query.
3. SQL:
CREATE VIEW NumberOfBedrooms AS
SELECT Bdrms, COUNT(*)
FROM CondoUnit
GROUP BY Bdrms;
SELECT *
FROM NumberOfBedrooms;
Access:
Create a query containing the Bdrms and CondoID fields from the CondoUnit table. Add the Totals row. Make sure
the entry in the Totals row for the Bdrms field is GroupBy and select Count as the entry in the Totals row for the
CondoID field. Save the query as NumberOfBedrooms. Run the query.
4. SQL:
a.
CREATE INDEX OwnerIndex1 ON Owner (State);
b.
CREATE INDEX OwnerIndex2 ON Owner (LastName);
c.
CREATE INDEX OwnerIndex3 ON Owner (State DESC, City);
Access:
©2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted
in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Concepts of Database Management, Eighth Edition Solutions 4-12
a. While viewing the Owner table in Design view, select Yes (Duplicates OK) for the Indexed property for
the State field.
b. While viewing the Owner table in Design view, select Yes (Duplicates OK) for the Indexed property for
the LastName field.
c. While viewing the Owner table in Design view, click the Indexes button in the Show/Hide group on the
Design tab, enter OwnerIndex3 as the name of the index, and then select the State and City fields. Select Descending
as the sort order for the State field.
5. SQL:
DROP INDEX OwnerIndex3;
Access:
While viewing the Owner table in Design view, click the Indexes button in the Show/Hide group on the Design tab,
and then delete the OwnerIndex3 index.
6. SQL:
a. CHECK (CondoFee < 1000)
CHECK (Bdrms > 0)
Access:
While viewing the CondoUnit table in Design view, change the Validation Rule property for the CondoFee field to
<1000 and the Validation Rule property for the Bdrms field to > 0.
7. SQL:
For the CondoUnit table:
FOREIGN KEY (LocationNum) REFERENCES Location
FOREIGN KEY (OwnerNum) REFERENCES Owner
For the ServiceRequest table:
FOREIGN KEY (CategoryNum) REFERENCES ServiceCategory
FOREIGN KEY (CondoID) REFERENCES CondoUnit
Access:
Create relationships between the CondoUnit and Location tables; between the CondoUnit and Owner tables;
between the ServiceRequest and Category tables; and between the ServiceRequest and CondoUnit tables. In each
relationship, select the option to enforce referential integrity.
8. SQL:
ALTER TABLE CondoUnit
ADD FeePaid CHAR (1);
UPDATE CondoUnit
SET FeePaid = 'Y';
Access:
While viewing the CondoUnit table in Design view, add a new field named FeePaid with the Short Text data type
and a Field Size property of 1. Create an Update query. Select the FeePaid field and enter Y as the Update to value.
Do not enter any criteria. Run the Update query. Run a Select query to select all fields from the CondoUnit table.
9. SQL:
UPDATE CondoUnit
SET FeePaid=′N′
WHERE CondoID = 4;
Access:
While viewing the CondoUnit table in Datasheet view, select the record on which the CondoID is 4, select the
FeePaid field, and change the value in the field to N.
10. SQL:
ALTER TABLE Owner
CHANGE COLUMN LastName TO CHAR (30);
Access:
©2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted
in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Concepts of Database Management, Eighth Edition Solutions 4-13
While viewing the Owner table in Design view, select the LastName field, and then change the Field Size property
to 30.
11a. Open the Location table in Design view and add the TotalFees field with the currency data type. Create a totals
query on the CondoUnit table and group by location number and sum the condo fees. Open the Location table in Datasheet
view and update the TotalFees field with the appropriate values.
©2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted
in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Concepts of Database Management, Eighth Edition Solutions 4-14
12. [Critical Thinking] There would not be any problems in modifying the ServiceCategory table. Management would
need to query the ServiceRequest table to determine which requests currently for heating/air conditioning (category 2) should
be updated to category 7.
©2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted
in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.