图书馆理系统数据设计范列

--共六张表
create table userType(
userTypeId number primary key,
typeName varchar2(20),
maxBook number,
maxRentDay number,
--最大账户使用时间,默认3年有效期
maxRegisterDay number default(1080)
);
insert into usertype (usertypeid, typename, maxbook, maxrentday, maxregisterday) values ('1', '管理员', '100', '90', '1080');
insert into usertype (usertypeid, typename, maxbook, maxrentday, maxregisterday) values ('2', '学生', '10', '60', '1080');
insert into usertype (usertypeid, typename, maxbook, maxrentday, maxregisterday) values ('3', '冻结用户', '0', '60', '1080');


--创建用户表
create table users(
userId varchar2(50) not null primary key,
userName varchar2(50),
userPwd varchar2(50),
UserAdress varchar2(50),
bornDay date default(to_date('2010-5-20','yyyy-mm-dd')),
registerDate date,
idCard varchar2(50), 
phone varchar2(50),
sex number,
age number,
money number default(0),
userWorkPlace varchar2(255),
userTypeId number,
constraint fk_userType foreign key(userTypeId) references userType(userTypeId)
);
insert into users (userid, username, userpwd, useradress, bornday, registerdate, idcard, phone, sex, age, money, userworkplace, usertypeid) values ('1000', '李四', '123456', '中国', to_date('2014-05-05 04:20:35', 'yyyy-mm-dd hh24:mi:ss'), to_date('2014-06-04 04:20:40', 'yyyy-mm-dd hh24:mi:ss'), '450999', '13255771', '1', '20', '10', '图书馆', '1');
insert into users (userid, username, userpwd, useradress, bornday, registerdate, idcard, phone, sex, age, money, userworkplace, usertypeid) values ('1001', '李五', '123456', '中国', to_date('2014-05-05 04:20:35', 'yyyy-mm-dd hh24:mi:ss'), to_date('2014-06-04 04:20:40', 'yyyy-mm-dd hh24:mi:ss'), '450999', '13255771', '1', '20', '10', '图书馆', '1');
insert into users (userid, username, userpwd, useradress, bornday, registerdate, idcard, phone, sex, age, money, userworkplace, usertypeid) values ('1002', '李六', '123456', '中国', to_date('2014-05-05 04:20:35', 'yyyy-mm-dd hh24:mi:ss'), to_date('2014-06-04 04:20:40', 'yyyy-mm-dd hh24:mi:ss'), '450999', '13255771', '1', '20', '10', '图书馆', '2');
insert into users (userid, username, userpwd, useradress, bornday, registerdate, idcard, phone, sex, age, money, userworkplace, usertypeid) values ('1003', '李七', '123456', '中国', to_date('2014-05-05 04:20:35', 'yyyy-mm-dd hh24:mi:ss'), to_date('2014-06-04 04:20:40', 'yyyy-mm-dd hh24:mi:ss'), '450999', '13255771', '1', '20', '10', '图书馆', '2');
insert into users (userid, username, userpwd, useradress, bornday, registerdate, idcard, phone, sex, age, money, userworkplace, usertypeid) values ('1004', 'admin', 'admin', '中国', to_date('2014-05-05 04:20:35', 'yyyy-mm-dd hh24:mi:ss'), to_date('2014-06-04 04:20:40', 'yyyy-mm-dd hh24:mi:ss'), '450999', '13255771', '1', '20', '10', '图书馆', '1');








--创建书类别表
create table bookType(
bookType number primary key,
bookName varchar2(100)
);
--插入测试数
insert into bookType(bookType,bookName) values(1,'计算机');
insert into bookType(bookType,bookName) values(2,'报纸杂志');
insert into bookType(bookType,bookName) values(3,'工具数');
insert into bookType(bookType,bookName) values(4,'文学');


--创建书类表
create table book(
serialId varchar2(100) primary key,
bookName varchar2(100),
authour varchar2(100),
publish varchar2(100),
publishDate date default(to_date('2014-1-1','yyyy-mm-dd')),
comments varchar2(100),
bookPosition varchar2(100),
bookImageUrl varchar2(100),
bookType number,
bookResource number,
rentTimes number,
bookPrice number,
--约束
constraint fk_bookType foreign key(bookType) references bookType(bookType)
);
insert into book(serialid, bookname, authour, publish, publishdate, comments, bookposition, bookimageurl, booktype, bookresource, renttimes, bookprice) values ('10001', 'java编程思想', '乔恩', '美国时代', to_date('2013-06-05 15:42:12', 'yyyy-mm-dd hh24:mi:ss'), '很好', '计算机书库', 'd:\bookimage', '1', '1', '100', '120');
insert into book(serialid, bookname, authour, publish, publishdate, comments, bookposition, bookimageurl, booktype, bookresource, renttimes, bookprice) values ('10002', 'java', '乔恩', '美国时代', to_date('2013-06-05 15:42:12', 'yyyy-mm-dd hh24:mi:ss'), '很好', '计算机书库', 'd:\bookimage', '1', '1', '100', '120');
insert into book(serialid, bookname, authour, publish, publishdate, comments, bookposition, bookimageurl, booktype, bookresource, renttimes, bookprice) values ('10003', 'java编程', '乔*恩', '美国时代', to_date('2013-06-05 15:42:12', 'yyyy-mm-dd hh24:mi:ss'), '很好', '计算机书库', 'd:\bookimage', '1', '1', '100', '120');
insert into book(serialid, bookname, authour, publish, publishdate, comments, bookposition, bookimageurl, booktype, bookresource, renttimes, bookprice) values ('10004', 'java类思想', '乔布斯', '美国时代', to_date('2013-06-05 15:42:12', 'yyyy-mm-dd hh24:mi:ss'), '很好', '计算机书库', 'd:\bookimage', '1', '1', '100', '120');






--创建借阅表
create table rent(
--流水号
rentserial varchar2(100) primary key,
rentday date,
returndate date,
userId varchar2(50),
--书序列
serialId varchar2(100),
--约束
constraint fk_userId foreign key(userId) references users(userId)
);


insert into rent (rentserial, rentday, returndate, userid, serialid) values ('100200', to_date('2014-06-03 15:48:23', 'yyyy-mm-dd hh24:mi:ss'), to_date('2014-06-27 15:48:28', 'yyyy-mm-dd hh24:mi:ss'), '1001', '10001');
insert into rent (rentserial, rentday, returndate, userid, serialid) values ('100201', to_date('2014-06-03 15:48:23', 'yyyy-mm-dd hh24:mi:ss'), to_date('2014-06-27 15:48:28', 'yyyy-mm-dd hh24:mi:ss'), '1001', '10001');
insert into rent (rentserial, rentday, returndate, userid, serialid) values ('100202', to_date('2014-06-03 15:48:23', 'yyyy-mm-dd hh24:mi:ss'), to_date('2014-06-27 15:48:28', 'yyyy-mm-dd hh24:mi:ss'), '1001', '10001');
insert into rent (rentserial, rentday, returndate, userid, serialid) values ('100203', to_date('2014-06-03 15:48:23', 'yyyy-mm-dd hh24:mi:ss'), to_date('2014-06-27 15:48:28', 'yyyy-mm-dd hh24:mi:ss'), '1001', '10001');






--罚款表
create table paymoney(
rentserial varchar2(100),
paymoney number,
returndate date,
userId varchar2(50),
bookType number,
--约束
constraint fk_rentserial foreign key(rentserial) references rent(rentserial)
);


insert into paymoney (rentserial, paymoney, returndate, userid, booktype) values ('100200', '10', to_date('2014-06-30 15:58:58', 'yyyy-mm-dd hh24:mi:ss'), '1001', '1');
insert into paymoney (rentserial, paymoney, returndate, userid, booktype) values ('100200', '10', to_date('2014-06-30 15:58:58', 'yyyy-mm-dd hh24:mi:ss'), '1001', '1');
insert into paymoney (rentserial, paymoney, returndate, userid, booktype) values ('100200', '10', to_date('2014-06-30 15:58:58', 'yyyy-mm-dd hh24:mi:ss'), '1001', '1');

你可能感兴趣的:(图书馆理系统数据设计范列)