Victoria Becu

Generate statements (ddl) to create all objects

I made 3 tables relating back to the College table. I set primary keys (e.g. ID_#, College_ID) and based my foreign keys on them.

  • December 16, 2016 at 9:29 PM
  • Visible to public
CREATE TABLE College
(
Major VARCHAR(30) NOT NULL,
Department VARCHAR(30) NOT NULL,
College_Name VARCHAR(30) NOT NULL,
College_ID INT NOT NULL,
PRIMARY KEY(College_ID)
);

CREATE TABLE Course
(
TA VARCHAR(40) NOT NULL,
Professor VARCHAR(40) NOT NULL,
Section INT NOT NULL,
Course_ID INT NOT NULL,
Course_Name VARCHAR(20) NOT NULL,
College_ID INT NOT NULL, 
PRIMARY KEY(Course_ID),
FOREIGN KEY(College_ID) REFERENCES College(College_ID)
);

CREATE TABLE Student
(
Major VARCHAR(30) NOT NULL,
Username VARCHAR(10) NOT NULL,
ID_# INT NOT NULL,
Course_ID INT NOT NULL,
College_ID INT NOT NULL,
PRIMARY KEY(ID_#),
FOREIGN KEY(Course_ID) REFERENCES Course(Course_ID),
FOREIGN KEY(College_ID) REFERENCES College(College_ID)
);