Appendix A – Getting Started with Microsoft SQL Server 2016
© 2018 Pearson Education, Inc. Page 20 of 33
One important consideration here is foreign key constraints. Note that we link to both
the EMPLOYEE table using EmployeeNumber and to the COMPUTER table using
SerialNumber. What referential integrity constraints should we use?
For EMPLOYEE, EmployeeNumber is a surrogate key and is never updated. Further, WP
never drops employee records because of record keeping requirements. Therefore, we
will never cascade updates or deletes for this primary key.
FOR COMPUTER, SerialNumber never changes. However, when we remove a computer
from the WP computer inventory, we do not need to keep historical records of having
had that computer. Therefore, while we do not cascade updates, we will cascade
deletions for this primary key.
Here is the final SQL statement to create the COMPUTER_ASSIGNMENT table:
/* *** SQL-CREATE-TABLE-AppA-EX-01 *** */
CREATE TABLE COMPUTER_ASSIGNMENT(
SerialNumber Int NOT NULL,
EmployeeNumber Int NOT NULL,
4. Run the SQL-CREATE-TABLE-AppA–EX-01 statement. The result is shown in the screen
shot on the next page.