Uploaded by Silhig Lanot

Database

advertisement
Assignment 1
Use the Table below to answer questions 1.1 to 1.3.
1.1 Using correct terminology, identify and describe all the fields in Table Employee.
1.2
Primary key – EmpID: This is the unique identifier for each employee.
EmpLName: This is the employee’s last name.
EmpInit: This is the employee’s middle initial.
EmpFName: This is the employee’s first name
Foreign key – EmpJobCode: This is the code for the employee’s job.
How many records are shown?
There are four records shown in Table Employee.
1.3 How many attributes are shown
1.4
There are five attributes shown in Table Employee.
The database below is composed of two tables. Use these tables to answer questions 2.1 to 2.4.
2.1 Identify the primary key for each table.
The primary key for the DIRECTOR table is DirNum.
The primary key for the PLAY table is PlayNo.
2.2 Identify the foreign key in the PLAY table.
The foreign key in the PLAY table is DirNum, which references the DirNum attribute in the DIRECTOR
table.
2.3 Identify the candidate keys in both tables.
As the single attribute that may be used to distinguish each director, DirNum is the only candidate key
in the DIRECTOR table. There are no other qualities in the PLAY table that may be used to distinguish
one play from another; PlayNo is the only key. The PLAY table therefore lacks any more candidate
keys.
2.4 Does the PLAY table exhibit referential integrity? Why or why not?
The PLAY table does indeed display referential integrity. This is so because the DirNum attribute in the
PLAY table uses the DirNum attribute in the DIRECTOR table as a foreign key. This means that in order
to avoid violating the referential integrity constraint, the values in the DirNum attribute of the PLAY
table must match a value in the DirNum attribute of the DIRECTOR table.
Suppose you are using the database in the next slide, composed of the two tables. Use these tables to
answer questions 3.1 to 3.5.
3.1 Identify the primary key in each table.
The primary key in the CUSTOMER table is CustID.
The primary key in the BookOrders table is OrderID.
3.2 Identify the foreign key in the BookOrders table.
The foreign key in the BookOrders table is CustID, which references the CustID attribute in the
CUSTOMER table.
3.3 Are there any candidate keys in either table?
CustID and AcctNo are the potential keys in the CUSTOMER table. There are no additional qualities
that can specifically identify each book order; OrderID is the only attribute that can do so in the
BookOrders database. As a result, the BookOrders table has no additional potential keys.
3.4 Does the BookOrders table exhibit referential integrity? Why or why not?
Indeed, the referential integrity of the BookOrders table is present. This is so because the CustID
attribute in the BookOrders table, which refers to the CustID attribute in the CUSTOMER table, is a
foreign key. This means that in order to avoid violating the referential integrity constraint, the values
in the CustID attribute of the BookOrders database must match a value in the CustID attribute of the
CUSTOMER table.
3.5 Do the tables contain redundant data? If so which table(s) and what is the redundant data?
Redundant data can be found in the tables. When the Rapunzel and Peter Pan books are repeated
with the same price, the CUSTOMER table contains redundant data.
Download