博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
为什么mysql创建不_求教,,为什么创建不了表
阅读量:6513 次
发布时间:2019-06-24

本文共 2781 字,大约阅读时间需要 9 分钟。

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

create table classroom

(buildingvarchar(15),

room_numbervarchar(7),

capacitynumeric(4,0),

primary key (building, room_number)

);

create table department

(dept_namevarchar(20),

buildingvarchar(15),

budget numeric(12,2) check (budget > 0),

primary key (dept_name)

);

create table course

(course_idvarchar(8),

titlevarchar(50),

dept_namevarchar(20),

creditsnumeric(2,0) check (credits > 0),

primary key (course_id),

foreign key (dept_name) references department

on delete set null

);

create table instructor

(IDvarchar(5),

namevarchar(20) not null,

dept_namevarchar(20),

salarynumeric(8,2) check (salary > 29000),

primary key (ID),

foreign key (dept_name) references department

on delete set null

);

create table section

(course_idvarchar(8),

sec_idvarchar(8),

semestervarchar(6)

check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),

yearnumeric(4,0) check (year > 1701 and year < 2100),

buildingvarchar(15),

room_numbervarchar(7),

time_slot_idvarchar(4),

primary key (course_id, sec_id, semester, year),

foreign key (course_id) references course

on delete cascade,

foreign key (building, room_number) references classroom

on delete set null

);

create table teaches

(IDvarchar(5),

course_idvarchar(8),

sec_idvarchar(8),

semestervarchar(6),

yearnumeric(4,0),

primary key (ID, course_id, sec_id, semester, year),

foreign key (course_id,sec_id, semester, year) references section

on delete cascade,

foreign key (ID) references instructor

on delete cascade

);

create table student

(IDvarchar(5),

namevarchar(20) not null,

dept_namevarchar(20),

tot_crednumeric(3,0) check (tot_cred >= 0),

primary key (ID),

foreign key (dept_name) references department

on delete set null

);

create table takes

(IDvarchar(5),

course_idvarchar(8),

sec_idvarchar(8),

semestervarchar(6),

yearnumeric(4,0),

grade varchar(2),

primary key (ID, course_id, sec_id, semester, year),

foreign key (course_id,sec_id, semester, year) references section

on delete cascade,

foreign key (ID) references student

on delete cascade

);

create table advisor

(s_IDvarchar(5),

i_IDvarchar(5),

primary key (s_ID),

foreign key (i_ID) references instructor (ID)

on delete set null,

foreign key (s_ID) references student (ID)

on delete cascade

);

create table time_slot

(time_slot_idvarchar(4),

dayvarchar(1),

start_hrnumeric(2) check (start_hr >= 0 and start_hr < 24),

start_minnumeric(2) check (start_min >= 0 and start_min < 60),

end_hrnumeric(2) check (end_hr >= 0 and end_hr < 24),

end_minnumeric(2) check (end_min >= 0 and end_min < 60),

primary key (time_slot_id, day, start_hr, start_min)

);

create table prereq

(course_idvarchar(8),

prereq_idvarchar(8),

primary key (course_id, prereq_id),

foreign key (course_id) references course

on delete cascade,

foreign key (prereq_id) references course

);

转载地址:http://rvifo.baihongyu.com/

你可能感兴趣的文章
今年以来硅晶圆涨幅约达40%
查看>>
构建智能的新一代网络——专访Mellanox市场部副总裁 Gilad Shainer
查看>>
《数字视频和高清:算法和接口》一导读
查看>>
《中国人工智能学会通讯》——6.6 实体消歧技术研究
查看>>
如何在Windows查看端口占用情况及查杀进程
查看>>
云存储应用Upthere获7700万美元股权债务融资
查看>>
国家互联网应急中心何世平博士主题演讲
查看>>
洗茶,你误会了多少年?
查看>>
贵阳高新区力争打造“千亿级大数据园区”
查看>>
安防众筹不止于卖产品 思维拓展刺激消费
查看>>
OpenSSH曝高危漏洞 会泄露私钥
查看>>
艾特网能获2016APCA用户满意品牌大奖
查看>>
《CCNP TSHOOT 300-135学习指南》——第2章 结构化故障检测与排除进程
查看>>
《Java EE 7精粹》—— 2.5 非阻塞I/O
查看>>
《R数据可视化手册》——1.1 安装包
查看>>
spring-aop
查看>>
android RecycleView Adapter简单封装
查看>>
Dart的数据库操作
查看>>
Codeforces 591 B Rebranding【Codeforces Round #327 (Div. 2)】
查看>>
命名难,难于上青天
查看>>