Week 3 Flashcards
What is the DDL statement for this table
CREATE TABLE Students
(sid TEXT,
name TEXT,
login TEXT,
age INTEGER,
gpa REAL);
“For a given student and course, there is a single grade in Enrolled” What is the DDL statement
CREATE TABLE Enrolled
(sid VARCHAR(20)
cid VARCHAR(20),
grade VARHAR(2),
PRIMARY KEY (sid,cid) );
Create Enrolled table, “Students can take only one course, and receive a single grade for that course; further, no two students in a course receive the same grade.”
CREATE TABLE Enrolled
(sid VARCHAR(20)
cid VARCHAR(20),
grade VARCHAR(2),
PRIMARY KEY (sid),
UNIQUE (cid, grade) );
CREATE TABLE Works_In(
ssn VARCHAR(1),
did INTEGER,
since TEXT,
PRIMARY KEY (ssn, did), FOREIGN KEY (ssn)
REFERENCES Employees(ssn),
FOREIGN KEY Departments (did)
REFERENCES Departments (did) );
CREATE TABLE Enrolled
(sid VARCHAR(20), cid VARCHAR(20), grade VARCHAR(2),
PRIMARY KEY (sid,cid),
FOREIGN KEY (sid) REFERENCES Students (sid) );
CREATE TABLE Enrolled
(sid VARCHAR(20), cid VARCHAR(20), grade VARCHAR(2),
PRIMARY KEY (sid,cid),
FOREIGN KEY (sid) REFERENCES Students (sid) );
CREATE TABLE Dep_Policy (
pname VARCHAR(20),
age INTEGER,
cost REAL,
ssn VARCHAR(11) NOT NULL,
PRIMARY KEY (pname, ssn),
FOREIGN KEY (ssn) REFERENCES Employ