最新Oracle图书管理系统.doc
Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-dateOracle图书管理系统Oracle图书管理系统2.1课程设计目的通过专业课程设计,即大型数据库系统课程设计,有助于培养学生综合运用数据库相关知识解决实际问题的能力。本设计要求对实际问题进行需求分析,提炼实际问题中的数据,建立关系模型,并在大型数据库中得以实现。同时要求对数据库的运营、管理及使用上进行必要的规划和实现。2.2课程设计任务基本任务:(1)根据需求,补充必要的数据库实体,建立ER模型,通过ER图表示。(2)在Oracle中创建该系统的数据库,并在数据库中实现各表,写入一定的数据。(3)从实际查询应用出发,为一些主要的应用模块设计至少3个参数化视图。(4)从数据检验的角度出发,为相关的表建立至少1个触发器。(5)从数据更新或修改的角度出发,设计至少1个存储过程。(6)从安全的角度出发,规划系统的角色、用户、权限,并通过相关的SQL实现。(7)预计每个表的大致容量和增长速度,指定备份的方案,写出相关的备份命令。3.2 表空间及表的设计create table book( bno varchar(10) primary key, bname varchar(40) not null, writer varchar(30) not null, btype varchar(8), price float, storenum int, pub varchar(50), pubday varchar(15);create table reader( rno varchar(10) primary key, rname varchar(20) not null, sex varchar(2) check(sex='男'or sex='女'), type varchar(8) not null, bwnum int not null, depart varchar(20), phone varchar(15) not null));create table b_borrow( bno varchar(10), rno varchar(10), primary key(bno,rno), rname varchar(20) not null, bwday varchar(10) not null, bkday varchar(10) not null, foreign key(bno) references book(bno), foreign key(rno) references reader(rno) );create table bmanager( mno varchar(10) primary key, mname varchar(20) not null, msex varchar(2) check(msex='男'or msex='女'), mphone varchar(15) not null, address varchar(20) not null);create table b_manage(mno varchar(10), bno varchar(10), primary key (mno,bno), mname varchar(20) not null, tnum int not null, addtime varchar(10), bwtimes varchar(8) not null, foreign key(mno) references bmanager(mno), foreign key(bno) references book(bno) );create table r_manage(mno varchar(10), rno varchar(10), primary key (mno,rno), rname varchar(20), back varchar(2) check(back='是'or back='否'), foreign key(mno) references bmanager(mno), foreign key(rno) references reader(rno) );create table m_rule(mno varchar(10), rno varchar(10), primary key (mno,rno), rname varchar(20) not null, rtype varchar(10) check(rtype='丢失赔款'or rtype=损坏赔偿 or rtype='逾期罚款') not null, cashnum varchar(10) not null, foreign key(mno) references bmanager(mno), foreign key(rno) references reader(rno) );3.3 视图设计create view bookview as select * from book where btype='计算机'with check option;create view readerviewas select * from readerwhere sex='女'with check option;create viewborrowinfo(bno,bname,storenum,btype,tnum,bwtimes)as select b.bno,bname,storenum,btype,tnum,bwtimesfrom book b,b_manage mwhere b.bno=m.bno with check option;3.4 存储过程、函数的设计create or replace procedure show_reader(p_rno reader.rno%type)asv_bwnum reader.bwnum%type;beginselect avg(bwnum) into v_bwnum from reader where rno=p_rno;dbms_output.put_line(p_rno|' '|'平均借书数是多少:'|v_bwnum);for v_reader in (select rno,rname,type from reader where rno=p_rno and bwnum>v_bwnum)loopdbms_output.put_line(v_reader.rno|' '|v_reader.rname|' '|v_reader.type);end loop;exceptionwhen no_data_found thendbms_output.put_line('不存在最高借书数的读者!');end show_reader;过程已创建。execute show_reader(5);PL/SQL 过程已成功完成。3.5 触发器设计触发器create or replace trigger trig_viewinstead of insert on borrowinfofor each rowdeclarev_bno b_manage.bno%type;beginselect bno into v_bno from b_manage where tnum=:new.tnum and bwtimes=:new.bwtimes;insert into book(bno,bname,storenum,btype)values(:new.bno,:new.bname,:new.storenum,:new.btype);end trig_view;触发器已创建。-