数据库上机

时间:2022-11-24 10:09:22 作者:壹号 字数:2822字

create table employ(
ecardid char(20),
eid char(20) not null,
ename char(20) not null,
esex char(20) not null,
etelenum char(20),
position char(20),
primary key (eid),
check (esex in ('男','女')),
check(position in('员工'))
)
create table manage(
mcardid char(20),
mid char(20) not null,
mname char(20) not null,
msex char(20) not null,
mtelenum char(20),
position char(20),
primary key (mid),
check (msex in ('男','女')),
check(position in('经理'))
)
create table menu(
dishno char(20),
danjia float(20) not null unique,
dishname char(20) not null unique,
pingzong char(20),
worktime char(20),
shiduan char(20) not null unique,
primary key(dishno),
check(pingzong in('主菜','特价菜','酒水','主食')),
check (shiduan in('早','中','晚'))
)
create table work(
mid char(20),
eid char(20),
worktime char(20),
shiduan char(20) ,
riqi char(20),
primary key(mid),
check (worktime in('星期一','星期二','星期三','星期四','星期五')),
check (shiduan in('早','中','晚')),
foreign key (mid) references manage(mid),
foreign key (eid) references employ(eid),
foreign key (shiduan) references menu(shiduan)
)

create table discount (
num char(20),
discount char(20),
dishname char(20) not null,
pingzong char(20),
primary key(num),
check (pingzong in('主菜')),
foreign key (dishname) references menu(dishname)
)

create table xiadan(
eid char(20),
shiduan char(20) not null,
dishname char(20) not null,
qty smallint,
danjia float(20) not null,
num char(20) not null,
primary key(eid),
foreign key (eid) references employ(eid),
foreign key (shiduan) references menu(shiduan),
foreign key (dishname) references menu(dishname),

foreign key (num) references discount(num)
)
create database restaurant
create table manage(
mcardid char(20),
mno char(20) not null unique ,
mname char(20) not null,
msex char(20) not null,
mtelenum char(20),
position char(20),
primary key (mno),
check (msex in ('男','女')),
check(position in('经理'))
)
create table employ(
ecardid char(20),
eno char(20) not null,
ename char(20) not null,
esex char(20) not null,
etelenum char(20),
position char(20),
primary key (eno),
check (esex in ('男','女')),
check(position in('员工'))
)
create table breakfast(
bname char(20),
bno char(20),
bprice float(3),
primary key (bno)
)
drop table lunch;
create table lunch(
lname char(20) not null unique,
lno char(20),
ltype char(20) not null unique,
lprice float(3) not null unique,
primary key (lno),
check (ltype in('zucai','zushi','jiushui','tenjiacai'))
)
create table super(
sname char(20),
sno char(20),
sprice float(3),
primary key (sno)
)
create table worktime(
mno char(20) not null,
eno char(20),
dailytime char(20),
fhours smallint,
shours smallint,
dates char(20),
primary ke
y(dates,mno),
check (dailytime in('morning','noon','night')),
check ((fhours-shours)=5 and (shours=6 or shours=11 or shours=16) and (fhours=11