Week 3 Flashcards

1
Q

What is the DDL statement for this table

A

CREATE TABLE Students
(sid TEXT,
name TEXT,
login TEXT,
age INTEGER,
gpa REAL);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

“For a given student and course, there is a single grade in Enrolled” What is the DDL statement

A

CREATE TABLE Enrolled
(sid VARCHAR(20)
cid VARCHAR(20),
grade VARHAR(2),
PRIMARY KEY (sid,cid) );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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.”

A

CREATE TABLE Enrolled
(sid VARCHAR(20)
cid VARCHAR(20),
grade VARCHAR(2),
PRIMARY KEY (sid),
UNIQUE (cid, grade) );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
A

CREATE TABLE Enrolled
(sid VARCHAR(20), cid VARCHAR(20), grade VARCHAR(2),
PRIMARY KEY (sid,cid),
FOREIGN KEY (sid) REFERENCES Students (sid) );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
A

CREATE TABLE Enrolled
(sid VARCHAR(20), cid VARCHAR(20), grade VARCHAR(2),
PRIMARY KEY (sid,cid),
FOREIGN KEY (sid) REFERENCES Students (sid) );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly