数据库SQL语句实现

1、创建数据库
create database if not exists cs2013;
2、创建数据库表格
create table if not exists comp (
	id int not null primary key auto_increment ,
	pid varchar(30) not null unique ,
	cname varchar(30) not null ,
	ename varchar(30) not null ,
	grade varchar(30) not null , 
	sex int not null ,
	clothe varchar(15) not null
)default charset = utf8;

create table if not exists team (
	id int not null primary key auto_increment ,
	cname varchar(30) not null ,
	ename varchar(30) not null ,
	coach0 int not null , 
	coach1 int not null ,
	stu0 int not null ,
	stu1 int not null ,
	stu2 int not null ,
	isgirls int not null ,
	email varchar(30) not null ,
	phone varchar(15) not null ,
	foreign key (coach0) references comp(id) ,
	foreign key (coach1) references comp(id) ,
	foreign key (stu0) references comp(id) ,
	foreign key (stu1) references comp(id) ,
	foreign key (stu2) references comp(id)
)default charset = utf8;

create table if not exists college (
	id int not null primary key auto_increment,
	cname varchar(30) not null ,
	ename varchar(30) not null ,
	teamcnt int not null
)default charset = utf8;

create table if not exists rc (
	id int not null primary key auto_increment ,
	college int not null ,
	team int not null ,
	date date not null ,
	foreign key (college) references college (id) ,
	foreign key (team) references team (id)
)default charset = utf8;

create table if not exists room (
	id int not null primary key auto_increment,
	name varchar(30) not null ,
	totcnt int not null ,
	regcnt int not null ,
	price double not null
)default charset = utf8;

create table if not exists hotel (
	id int not null primary key auto_increment,
	name varchar(30) not null ,
	room0 int not null ,
	room1 int not null ,
	room2 int not null ,
	foreign key (room0) references room (id) ,
	foreign key (room1) references room (id) ,
	foreign key (room2) references room (id)
)default charset = utf8;

create table if not exists rh (
	id int not null primary key auto_increment,
	college int not null ,
	hotel int not null ,
	date date not null ,
	foreign key (college) references college (id) ,
	foreign key (hotel) references hotel (id)
)default charset = utf8;


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值