Create the four 3NF registrar tables (reg_instructor, reg_student, reg_course, reg_grade) with PRIMARY KEY, FOREIGN KEY REFERENCES, NOT NULL, CHECK, and DEFAULT constraints. Type and run the DDL.
Create the four 3NF registrar tables (reg_instructor, reg_student, reg_course, reg_grade) with PRIMARY KEY, FOREIGN KEY REFERENCES, NOT NULL, CHECK, and DEFAULT constraints. Type and run the DDL.
Answer
CREATE TABLE reg_instructor ( instructor_name text PRIMARY KEY, instructor_location text NOT NULL ); CREATE TABLE reg_student ( student_id int PRIMARY KEY, student_name text NOT NULL, campus_address text, major text DEFAULT 'Undeclared' ); CREATE TABLE reg_course ( course_id int PRIMARY KEY, course_title text NOT NULL, instructor_name text REFERENCES reg_instructor(instructor_name) ); CREATE TABLE reg_grade ( student_id int REFERENCES reg_student(student_id), course_id int REFERENCES reg_course(course_id), grade text CHECK (grade IN ('A','B','C','D','F')), PRIMARY KEY (student_id, course_id) );