Uploaded by Thanakrit Lerdmatayakul

Chapter 7

advertisement
2601326 Analysis and Design of Accounting Database Spring 2023
Ch.7 Review Questions/Exercises
Project Questions
•
Use “Figures 7-44, 7-45, 7-46, 7-47, 7-48” attached to answer the following “6 Questions”.
•
For Questions 1-2, SQL statements are not needed.
•
For Questions 3-6, you will need to use MS SQL Server to write SQL statements and obtain SQL
query results.
•
Note: You can ignore SQL statements related to the EMPLOYEE table because this table is not
needed for this exercise.
Figure 7-45 - Column Characteristics for the COMPUTER Table
Figure 7-46 - Column Characteristics for the COMPUTER_ASSIGNMENT Table
Figure 7-47 - WPC Database COMPUTER Table Data
Figure 7-48 – WPC Database COMPUTER_ASSIGNMENT Table Data
•
Question #1: Describe the relationships in terms of type (identifying or nonidentifying) and
maximum and minimum cardinality.
RELATIONSHIP
PARENT
•
CHILD
Question #2: Explain the need for each of the foreign keys.
CARDINALITY
TYPE
MAX
MIN
Create a new database called “WPC” in the MS SQL Server and follow the instructions below.
•
Question #3: Write CREATE TABLE statements for the COMPUTER and
COMPUTER_ASSIGNMENT tables in Figure 7-44 using the column characteristics shown in
Figures 7-45 and 7-46. Write CHECK constraints to ensure that Make is Dell, HP, or Other. Also,
write constraints to ensure that ProcessorSpeed is between 2.0 and 5.0 (these are units of
Gigahertz). Run these statements on your WPC database to extend the database structure.
•
Question #4: Using the sample data for the COMPUTER table shown in Figure 7-47 and the
COMPUTER_ASSIGNMENT table shown in Figure 7-48, write INSERT statements to add this
data to these tables in the WPC database. Run these INSERT statements to populate the tables.
•
Question #5: Create a view called ComputerMakeView that shows the Make and average
ProcessorSpeed for all computers. Run this statement, and then test with an SQL SELECT
statement.
•
Question #6: Create a view called ComputerUserView that has all of the data of COMPUTER
and COMPUTER_ASSIGNMENT. Run this statement, and then test with an SQL SELECT
statement.
(Note that when creating a view for Question #6, you should avoid using the SELECT * statement
to get all data from both tables. This would create two columns named SerialNumber. To avoid
the duplicated column name problem, refer to the SerialNumber from one of the two tables.)
Download