图书表B(Bno, Bname, Bauthor, Bprice, Pname,Pdate),分别为:图书编号,图书名称,图书作者,图书单价,出版社名称,出版日期; 顾客表C (Cno, Cname, Csex, Cbirthday, Caddress,Cmobile),分别为:顾客编号,顾客姓名,顾客性别,顾客出生日期,顾客地址,顾客电话号码; 销售表S(Sno,Bno,Cno,Scount,Ssum,Sdate)分别为:销售编号,图书编号,顾客编号,销售数量,销售金额,销售日期; 库存表BW(Bno,Wno, num)分别为:图书编号,仓库编号,剩余库存; 仓库表W (Wno, Wname, Waddress)分别为:仓库编号,仓库名称,仓库地址。 其中,B由Bno唯一标识,C由Cno唯一标识,S由Sno唯一标识,BW由Bno和Wno唯一标识,W由Wno唯一标识,Pdate和Sdate格式为YYYY-MM-DD。给出上述创建表的mysql语句
时间: 2024-03-08 22:47:01 浏览: 101
创建图书表B:
```mysql
CREATE TABLE B (
Bno INT(10) PRIMARY KEY,
Bname VARCHAR(50),
Bauthor VARCHAR(50),
Bprice DECIMAL(10, 2),
Pname VARCHAR(50),
Pdate DATE
);
```
创建顾客表C:
```mysql
CREATE TABLE C (
Cno INT(10) PRIMARY KEY,
Cname VARCHAR(50),
Csex VARCHAR(10),
Cbirthday DATE,
Caddress VARCHAR(100),
Cmobile VARCHAR(20)
);
```
创建销售表S:
```mysql
CREATE TABLE S (
Sno INT(10) PRIMARY KEY,
Bno INT(10),
Cno INT(10),
Scount INT(10),
Ssum DECIMAL(10, 2),
Sdate DATE,
CONSTRAINT fk_bno FOREIGN KEY (Bno) REFERENCES B(Bno),
CONSTRAINT fk_cno FOREIGN KEY (Cno) REFERENCES C(Cno)
);
```
创建库存表BW:
```mysql
CREATE TABLE BW (
Bno INT(10),
Wno INT(10),
num INT(10),
PRIMARY KEY (Bno, Wno),
CONSTRAINT fk_bno FOREIGN KEY (Bno) REFERENCES B(Bno),
CONSTRAINT fk_wno FOREIGN KEY (Wno) REFERENCES W(Wno)
);
```
创建仓库表W:
```mysql
CREATE TABLE W (
Wno INT(10) PRIMARY KEY,
Wname VARCHAR(50),
Waddress VARCHAR(100)
);
```
阅读全文