用命令提示符创建图书管理系统表(Mysql)

 

建立图书类别表

依次输入

create table bookcategory(

category_id int primary key,                                                                                                  (主键约束)

category varchar(20) nut null unique,                                                                                    (非空约束、唯一约束)

parent_id int not null

);

建立图书信息表:

依次输入:

create table bookinfo(
 book_id int primary key,
 book_category_id int,
 book_name varchar(20) not null unique,
author varchar(20) not null,
 price float(5,2) not null,
 press varchar(20) default'机械工业出版社',                                                                                    (默认约束)
 pubdate date not null,
store int not null,
constraint fk_bcid foreign key(book_category_id) references bookcategory(category_id)                (外键约束)
);

建立读者信息表

依次输入

create table readerinfo(
card_id char(18) primary key,
name varchar(20) not null,
sex enum('男','女','保密') default '保密',                                                                                      (默认约束)
age tinyint,
tel char(11) not null,
 balance decimal(7,3) default 200
);

借阅信息表

依次输入

create table borrowinfo(
book_id int,
card_id char(18),
borrow_date date not null,
return_date date  not null,
status char(1) not null,
primary key(book_id,card_id)
);

-------------学习于我要自学网

 

 

 

 

  • 6
    点赞
  • 41
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值