CREATE TABLE Staff (Username INTEGER PRIMARY KEY, Name VARCHAR(20) NOT NULL, RoomNumber INTEGER CHECK (Age BETWEEN 1 AND 20) );
The question is - Create the Courses table in a similar way, but also set CourseLeader to be a foreign key as specified. Add an action to the foreign key constraint: when the parent is deleted, this value wants to be set to null.
This is what I have typed -
CREATE TABLE Courses( CourseID INTEGER PRIMARY KEY, Title VARCHAR(50) NOT NULL, CourseLeader VARCHAR(15) NOT NULL, Primary Key, FOREIGN KEY (Name) REFERENCES Staff (USERNAME) ON DELETE SET NULL));
Can someone tell me what im doing wrong and also type in the right code.
This is not an assignment, just an exercise.
Any questions then please ask.
Staff (Username, Name, RoomNumber)
Courses (CourseID, Title, CourseLeader)
Classes (ClassID, CourseID, Tutor, Location, Trimester, Day, Time, Hours)
This post has been edited by Atli: 23 October 2013 - 07:59 AM
Reason for edit:: Use [code] tags when posting code.