create database mydb
use mydb
--建表
create table card
(
cno varchar(20) primary key,
[name] varchar(20),
class varchar(20)
)
create table books
(
bno varchar(20) primary key,
bname varchar(20),
author varchar(20),
price money,
quantity int
)
create table borrow
(
cno varchar(20),
bno varchar(20),
rdate datetime,
primary key(cno,bno),注:这里是双主键
foreign key(cno) references card(cno),
foreign key(bno) references books(bno)
)
use mydb
--建表
create table card
(
cno varchar(20) primary key,
[name] varchar(20),
class varchar(20)
)
create table books
(
bno varchar(20) primary key,
bname varchar(20),
author varchar(20),
price money,
quantity int
)
create table borrow
(
cno varchar(20),
bno varchar(20),
rdate datetime,
primary key(cno,bno),注:这里是双主键
foreign key(cno) references card(cno),
foreign key(bno) references books(bno)
)