~/ learn/ comp-378/ cards/ From 3NF to a Running Table: CREATE TABLE with Constraints
1 of 4

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) );

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/a94947f0-d132-45dc-b5b3-be4502240028/flashcard utf-8 LF