cs174a-hw1-part2-solutions - data Users are alerted or...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
8 ) (3.4) The primary key is the key selected by the DBA from among the group of candidate keys_ all of which uniquely identify a tuple. A superkey is a set of attributes that contains perhaps properly contains a key. 9 ) (3.6) A foreign key constraint is a statement of the form that one or more fields of a relation, say R, together refer to a second relation, say S. That is, the values in these fields of a tuple in R are either null or uniquely identify some tuple in S Thus, these fields of R should be a candidate or primary key For example, a student, uniquely identified by an sid, enrolled in a class must also be registered in the schools student database, say in a relation called Students. Therefore, the sid of a legal entry in the Class Enrollment relation must match an existing sid in the Students relation. Foreign key constraints are important because they provide safeguards for insuring the integrity of
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: data. Users are alerted or thwarted when they try to do something that does not make sense. This can help minimize errors in application programs or in data-entry. Referential integrity means all foreign key constraints are enforced 10) (3.14) CREATE TABLE Employees ( ssn CHAR(10), sal INTEGER, phone CHAR(13), PRIMARY KEY (ssn) ) CREATE TABLE Departments ( dno INTEGER, budget INTEGER, dname CHAR(20), PRIMARY KEY (dno) ) CREATE TABLE Works in ( ssn CHAR(10), dno INTEGER, PRIMARY KEY (ssn, dno), FOREIGN KEY (ssn) REFERENCES Employees, FOREIGN KEY (dno) REFERENCES Departments) CREATE TABLE Manages ( ssn CHAR(10), dno INTEGER, PRIMARY KEY (dno), FOREIGN KEY (ssn) REFERENCES Employees, FOREIGN KEY (dno) REFERENCES Departments) CREATE TABLE Dependents (ssn CHAR(10), name CHAR(10), age INTEGER, PRIMARY KEY (ssn, name), FOREIGN KEY (ssn) REFERENCES Employees, ON DELETE CASCADE )...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online