❑
The HelpDesk table stores the help desk requests by referencing records from
the other tables, and adding only two original pieces of data itself: the help
desk request description, and the station number.
The relationships between these tables are critical, because without them the
original significance of the information would be lost. The relationships are so
important that the database has tools to protect them. Primary keys were used
to ensure the integrity of the records within a table (by guaranteeing their
uniqueness); in a moment, we’ll meet foreign keys, which protect the integrity
of data spread over multiple tables.
In our database’s HelpDesk table, the data depicted in Figure 7.14 would be
stored physically as shown in Table 7.12.
Table 7.12. Sample data from the HelpDesk table
StatusIDDescriptionSubj'IDCat'IDStationN'berEmp'IDRequestID
(Primary
Key)
1Crashes when I
open documents
42531
1Crashes when I
start Solitaire
52342
Note that, apart from storing data about the request itself, the HelpDesk table
also has an ID column, named RequestID, which acts as the table’s primary key.
Foreign Keys
Technically speaking, a foreign key is a constraint that applies to a column that
refers to the primary key of another table. In practice, we’ll use the term “foreign
key” to refer to the column to which the constraint applies.
Unlike primary key columns, a foreign key column can contain NULL, and almost
always contains repeating values. The numeric columns in the HelpDesk table
that reference data from other tables (EmployeeID, CategoryID, SubjectID, and
StatusID), and the DepartmentID column in the Employees table, are perfect
candidates for the application of a foreign key constraint. Take a look at the ex-
amples shown in Table 7.13 and Table 7.14.
278
Chapter 7: Database Design and Development