-- drop tables
drop table Student CASCADE;
drop table Department CASCADE;
drop table Teacher CASCADE;
drop table Course CASCADE;
drop table Section CASCADE;
drop table Enrollment CASCADE;
drop table GpaLookup CASCADE;
-- create tables
CREATE TABLE Student
(
studentid CHAR(9) NOT NULL,
fname VARCHAR(20) NOT NULL,
lname VARCHAR(20) NOT NULL,
depname VARCHAR(40) NOT NULL,
year int NOT NULL,
email VARCHAR(30) NOT NULL,
phone VARCHAR(20) NOT NULL,
PRIMARY KEY (studentid)
);
CREATE TABLE Department
(
depid CHAR(4) NOT NULL,
depname VARCHAR(40) NOT NULL,
PRIMARY KEY (depid)
);
CREATE TABLE Teacher
(
teacherid CHAR(9) NOT NULL,
fname VARCHAR(20) NOT NULL,
lname VARCHAR(20) NOT NULL,
email VARCHAR(30) NOT NULL,
phone VARCHAR(20) NOT NULL,
office VARCHAR(20) NOT NULL,
hours VARCHAR(20) NOT NULL,
depid CHAR(4) NOT NULL,
PRIMARY KEY (teacherid),
FOREIGN KEY (depid) REFERENCES Department(depid)
);
CREATE TABLE Course
(
courseid CHAR(6) NOT NULL,
coursenumber VARCHAR(30) NOT NULL,
name VARCHAR(60) NOT NULL,
description VARCHAR(200),
www VARCHAR(30),
courselevel VARCHAR(10),
credit NUMERIC(2,0) NOT NULL,
depid CHAR(4) NOT NULL,
PRIMARY KEY (courseid),
FOREIGN KEY (depid) REFERENCES Department(depid)
);
CREATE TABLE Section
(
secid INT NOT NULL,
secterm CHAR(8) NOT NULL,
secyear CHAR(4) NOT NULL,
secbldg CHAR(6),
secroom CHAR(4) ,
sectime CHAR(10) ,
courseid CHAR(6) NOT NULL,
teacherid CHAR(9) NOT NULL,
PRIMARY KEY (secid),
FOREIGN KEY (courseid) REFERENCES Course(courseid)
);
CREATE TABLE Enrollment
(
studentid CHAR(9) NOT NULL,
secid INT NOT NULL,
grade VARCHAR(4) NOT NULL,
FOREIGN KEY (studentid) REFERENCES Student(studentid),
FOREIGN KEY (secid) REFERENCES Section(secid)
);
CREATE TABLE GpaLookup
(
grade VARCHAR(4) NOT NULL,
point Numeric(2,1) NOT NULL,
PRIMARY KEY (grade)
);
Create Tables
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- create() does not set password even if you pass the passw...
- Create groups 与 Create folder references是Xcode工程中添加文件的两种方...
- 先看下 stackoverflow上的解释 大致意思是说 Groups是 用来维护整个工程信息的途径,其并不反映文...
- 当我们xcode开发中,如何正确添加文件等资源? 可能很多人只是拖入文件资源,但是忘记勾选【creat...