数据库课程设计 银行储蓄管理系统
- 格式:doc
- 大小:162.50 KB
- 文档页数:15
《数据库系统概论》
课 程 设 计 报 告
设计题目: 银行储蓄管理系统
姓名:
学号:
班级:
设计起止时间:
需求分析:
在对软件工程相关知识学习之后,我们对设计软件有了基本的认识和一些应用技能。在数据库的课程设计中,我们计划做一个小型的银行储蓄管理系统,包括了基本的存取转,和管理员对日常工作的管理功能。
功能设计:
(1).客户:包括存款,取款,转账,查询余额,查看流水,密码修改功能
(2).管理员:新增用户,删除用户,查看用户,员工绩效,VIP用户判别,储备金预警分析。
3.功能流程图:银行管理系统登陆管理员客户销户查看员工绩效VIP判别资金储备金判别开户存款取款转账余额显示查看流水修改密码
详细设计:
1.E-R图模型 operatecustombankstaffCphoneCtimeCpassCRmoneyCnameCidBidSphoneSnameSidSpassSItimeBnameBmoneyBid111
2.根据E-R图设计关系表
(1).银行信息表(bank)
字段名 字段类型及长度 允许空 主键 说明
Bid nchar(9) no PK 银行号
Bname nchar(20) no 银行名
Bmoney numeric(20,3) no 银行余额
(2).客户信息表(custom)
字段名 字段类型及长度 允许空 主键 说明
Cid nchar(9) no PK 客户ID
Cname nchar(10) no 客户姓名
Cpass nchar(10) no 密码
Ctime nchar(20) no 注册时间
Bid nchar(9) no 所在银行行号
外码(Bank(Bid))
Crmoney numeric(10,3) no 账户余额
Cphone nchar(11) no 客户电话
(3).员工(管理员)表(staff)
字段名 字段类型及长度 允许空 主键 说明
Sid nchar(9) no PK 员工ID
Sname nchar(10) no 员工姓名
Spass nchar(10) no 登陆密码
SItime nchar(20) no 入行时间 Sphone nchar(11) no 联系电话
(4).流水信息表
字段名 字段类型及长度 允许空
主键
说明
Oid nchar(9) no PK 流水号
Cid nchar(9) no 客户ID 外码(Custom(Cid))
Bid nchar(9) no 银行ID 外码(Bank(Bid))
Sid nchar(9) no 员工ID 外码(Staff(Sid))
Otype smallint no 操作类型
Otime nchar(20) no 操作时间
Omoney numeric(10,3) yes 交易金额
OBmoney numeric(10,3) yes 上次余额
OAmoney numeric(10,3) yes 账户余额
三个实体:bank,staff,custom
一个联系:operate
关系图:
SQL语句:
/*建表*/
create table Bank
(Bid nchar(9) primary key,
Bname nchar(20) not null,
Bmoney numeric(20,3) not null
)
create table Custom
( Cid nchar(9) not null, Cname nchar(10) not null,
Cpass nchar(10) not null,
Ctype smallint not null,
Ctime nchar(20) not null,
Ccode nchar(18) not null,
Bid nchar(9) not null,
Crmoney numeric(10,3) not null,
Cphone nchar(11) not null,
primary key(Cid),
foreign key(Bid) references Bank(Bid) /*在客户表中以Bank表的主码作为一个外键,并对他进行级联更新*/
on update cascade,
)
create table Staff
(Sid nchar(9) primary key, /*在列级定义主码*/
Sname nchar(10) not null,
Spass nchar(10) not null,
SItime nchar(20) not null,
Sphone nchar(11) not null
)
create table Operate
(Oid nchar(9) not null,
Cid nchar(9) not null,
Bid nchar(9) not null,
Sid nchar(9) not null,
Otype nchar(10) not null,
Otime nchar(20) not null,
Oflag smallint not null,
Omoney numeric(10,3),
OBmoney numeric(10,3),
OAmoney numeric(10,3),
primary key(Oid,Cid,Sid),
foreign key (Cid) references Custom(Cid) /*以用户表主码为一个外键,进行级联删除*/
on delete cascade,
foreign key(Sid) references Staff(Sid) /*以员工表的主码作为外键,当删除引起冲突的时候,拒绝删除*/
on delete no action,
foreign key (Bid) references Bank(Bid)
on update cascade
)
insert into Bank values('00001','中国银行小寨分行',10000)
update Bank set Bname='中国银行经开分行' where Bid='00002'
select * from Bank;
delete from Bank where Bid='1' or Bid='2';
insert into Custom values('6505001','花花','111',0,'2012/12/10/08:26:00','610424199310100002','00001','1500','14345678912')
insert into Staff values('7985000','自助服务','111','2002/01/07','12331654613')
delete from Custom where Bid='2';
insert into Operate values('2406002','6505001','00001','7985001','哈哈','2012年12月18日14时12分',0,0,2900,2900)
insert into Operate values('2406005','6505007','00001','7985001','嘿嘿','2012年12月18日14时12分',0,0,2900,2900)
select * from Custom;
select * from Operate;
select * from Staff;
select * from Bank;
delete from Operate
drop table Custom
drop table Bank
drop table Staff;
drop table Operate;
select * from Bank;
delete from Operate where Oid='6505001'
drop view BMoney;
create view BMoney
as
select Omoney
from Operate
where Oflag = 0 and Omoney>2000 and Otype = '取款';
create view BInMoney
as
from Operate
where Oflag = 0 and Omoney>2000 and Otype='存款';
create view VIP
as
select Ctype
from Custom where Ctype=1;
select count(*) from BMoney;
select count(*) from BInMoney;
select count(*) from VIP;
update Bank set Bmoney='10000' where Bid='00001';
update Bank set Bmoney='+bmoney' where Bid='"+Bid+"'";
update Bank set Bmoney='10200.000000' where Bid='00001'
程序代码:
客户部分:
a. void CClientDlg::OnButtonIn() //存款函数
{
// TODO: Add your control notification handler code here
CInDlg InDlg;
if (InDlg.DoModal()==IDOK)
{double temp,temp1;
ADOConn ado;
CString sql = "select * from Custom where Cname='"+Cname+"'";
_RecordsetPtr ResultSet = ado.GetRecordSet((_bstr_t)sql);