图书管理系统--创建数据库和表.doc_第1页
图书管理系统--创建数据库和表.doc_第2页
图书管理系统--创建数据库和表.doc_第3页
图书管理系统--创建数据库和表.doc_第4页
图书管理系统--创建数据库和表.doc_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

/*1管理员表(L_Administrator)字段名字段说明数据类型约束备注a_id管理员编号intPrimary KeyIdentity(1000,1)a_name管理员姓名nvarchar(20)Not nulla_pwd管理员密码varchar(20)Not Null */ use Library gocreate table L_Administrator(a_id int not null primary key Identity(1000,1),a_name nvarchar(20) not null,a_pwd varchar(20) not null);/*2职务类型表(L_Duty)字段名字段说明数据类型约束备注d_id职务编号intPrimary KeyIdentity(1000,1)d_name职务名称nvarchar(20)Not nulld_maxcount最大借阅数量tinyintNot Null*/use Librarygocreate table L_Duty(d_id int not null primary key Identity(1000,1),d_name nvarchar(20) not null,d_maxcount tinyint not null);/*3读者表(L_Reader)字段名字段说明数据类型约束备注r_id读者编号bigintPrimary Keyr_name读者姓名nvarchar(20)Not Nullr_pwd读者密码varchar(20)Not Nullr_sex读者性别bitNot Nullr_typeid职务类型intForeign Key职务类型表的主键r_academy所在院系nVarchar(20)r_major专业nVarchar(20)r_contact联系方式Varchar(20)r_email邮箱nvarchar(20)r_photo读者照片nVarchar(100)存的是读者照片的路径*/use Librarygocreate table L_Reader(r_id bigint not null primary key,r_name nvarchar(20) not null,r_pwd varchar(20) not null,r_sex bit not null,r_typeid int not null,r_academy nvarchar(20),r_major nvarchar(20),r_contact varchar(20),r_email varchar(20),r_photo nvarchar(100);alter table L_Reader add constraint fk_dtypeid foreign key(r_typeid) references L_Duty(d_id)on delete cascadeon update cascade;/*创建一个存储过程*/use Librarygocreate procedure readerr_id bigint,r_name nvarchar(20),r_pwd varchar(20),r_sex bit,r_typeid int,r_academy nvarchar(20),r_major nvarchar(20),r_contact varchar(20),r_email varchar(20),r_photo nvarchar(100)asbegininsert into L_Reader(r_id,r_name,r_pwd,r_sex,r_typeid,r_academy,r_major,r_contact,r_email,r_photo)values(r_id,r_name,r_pwd,r_sex,r_typeid,r_academy,r_major,r_contact,r_email,r_photo);end/*4图书类型表(L_BookType)字段名字段说明数据类型约束备注bt_id类型编号intPrimary KeyIdentity(1000,1)bt_name类型名称nVarchar(20)Not null*/use Librarygocreate table L_BookType(bt_id int not null primary key Identity(1000,1),bt_name nvarchar(20) not null);/*5出版社信息表(L_Publishing)字段名字段说明数据类型约束备注ISBN国际标准图书编码char(13)Primary Keyp_name出版社名称nvarchar(30)Not Null*/use Librarygocreate table L_Publishing(ISBN char(13) not null primary key,p_name nvarchar(30) not null); /*6图书信息表(L_Book)字段名字段说明数据类型约束备注b_id图书编号Varchar(30)Primary KeyIdentity(1000,1)b_name图书名称nvarchar(30)Not NullISBN国际标准图书编码char(13)Foreign Key13位数字组成b_bkcaseid书架编号Varchar(20)b_price定价Numeric(10,2)b_author作者nvarchar(20)b_typeid类型编号intForeign Keyb_intime入库时间DateTimeb_synopsis图书简介Nvarchar(500)b_state图书状态bit0-借出,1-没有借出b_photo封面图片Nvarchar(100)存的是路径*/use Librarygocreate table L_Book(b_id varchar(20) not null primary key ,b_name nvarchar(30) not null,ISBN char(13),b_bkcaseid varchar(20),b_price Numeric(10,2) not null,b_author nvarchar(20),b_typeid int,b_intime DateTime,b_synopsis nvarchar(1000),b_state bit not null default 0,b_photo nvarchar(100);alter table L_Book add constraint fk_btypeid foreign key(b_typeid) references L_BookType(bt_id) on delete cascadeon update cascade;alter table L_Book add constraint fk_bisbn foreign key(ISBN) references L_Publishing(ISBN) on delete cascadeon update cascade;alter table L_Book drop column b_bkcaseid/*创建存储过程*/use Librarygocreate procedure bookb_name nvarchar(30),ISBN char(13),b_bkcaseid varchar(20),b_price numeric(10,2),b_author nvarchar(20),b_intime datetime,b_synopsis nvarchar(1000),b_photo nvarchar(100)asbegininsert into L_Book(b_name,ISBN,b_bkcaseid,b_price,b_author,b_intime,b_synopsis,b_photo)values(b_name,ISBN,b_bkcaseid,b_price,b_author,b_intime,b_synopsis,b_photo);end/*7借阅管理表(L_Borrow)字段名字段说明数据类型约束备注bw_id借阅编号intPrimary KeyIdentity(1,1)bw_bookid图书编号Varchar(20)Foreign Keybw_readerid读者编号IntForeign Keybw_outtime借出日期DateTimeNot Nullbw_endtime到期日期DateTimeNot Nullbw_backtime归还日期DateTimebw_isexpired是否过期BitNot Null默认为0-不过期bw_fine罚款数目Numeric(10,2)过期后才计算罚款数目*/use Librarygocreate table L_Borrow(bw_id int not null primary key Identity(1,1),bw_bookid varchar(20),bw_readerid bigint ,bw_outtime datetime not null,bw_endtime as dateadd(d,30,bw_outtime),bw_backtime datetime,bw_isexperied bit default 0,bw_fine numeric(10,2) default 0.00);alter table L_Borrow add constraint fk_bookid foreign key(bw_bookid) references L_Book(b_id)on delete cascadeon update cascade;alter table L_Borrow add constraint fk_readerid foreign key(bw_readerid) references L_Reader(r_id)on delete cascadeon update cascade;/*8图书资源表(L_Resource)字段名字段说明数据类型约束备注rs_id资源编号IntPrimary KeyIdentity(1000,1)rs_name资源名称nVarchar(30)Not nullrs_synopsis资源简介nVarchar(500)rs_amount资源大小int单位为KB或是MBrs_type资源类型Varchar(20)类似于doc、xsl、ppt、pdf、zip、rar、MP3、wmv等常用格式*/use Librarygocreate table L_Resource(rs_id int not null primary key Identity(1000,1),rs_name nvarchar(30) not null,rs_synopsis nvarchar(500),rs_amount bigint,rs_type varchar(20);/*9图书评论表(L_BookMarks)字段名字段说明数据类型约束备注ISBN国际标准图书编码char(13)Foreign Keybm_contents评论内容Nvarchar(500)Not Nullbm_time评论时间DateTimeNot Null*/use Librarygocreate table L_BookMarks(ISBN char(13) not null,bm_contents nvarchar(500) not null,bm_time datetime not null);alter table L_BookMarks add constraint fk_bmisbn foreign key(ISBN) references L_Publishing(ISBN)on delete cascadeon update cascade;/*10书架信息表(L_BookCase)字段名字段说明数据类型约束备注bc_id书架编号int

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论