create table dep
(
id
int primary key auto_increment,
name
varchar(6),
comment varchar(30)
);
create table employee
(
id
int primary key auto_increment,
name
varchar(10),
gender
varchar(5),
dep_id
int,
foreign key(dep_id
) references dep
(id
) on delete cascade on update cascade
);
create table author
(
id
int primary key auto_increment,
name
varchar(10)
);
create table book
(
id
int primary key auto_increment,
name
varchar(16)
);
create table author2book
(
id
int primary key auto_increment,
author_id
int,
book_id
int,
foreign key(author_id
) references author
(id
) on delete cascade on update cascade,
foreign key(book_id
) references book
(id
) on delete cascade on update cascade
);
create table customer
(
id
int primary key auto_increment,
name
varchar(16),
phone
char(11)
);
create table student
(
id
int primary key auto_increment,
class
varchar(10),
course
varchar(16),
c_id
int unique,
foreign key(c_id
) references customer
(id
) on delete cascade on update cascade
);
转载请注明原文地址:https://tech.qufami.com/read-852.html