【SSM-报销单】1.开始前准备

本文档主要介绍如何在SSM项目中进行报销单系统的数据库初始化,通过CMD命令行执行SQL文件完成数据表的创建。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

数据库

在这里插入图片描述
CMD下命令执行sql文件
在这里插入图片描述


drop database if exists oa;

create database oa;
use oa;

/*==============================================================*/
/* Table: claim_voucher                                         */
/*==============================================================*/
create table claim_voucher
(
   id                   int not null auto_increment,
   cause                varchar(100),
   create_sn            char(5),
   create_time          datetime,
   next_deal_sn         char(5),
   total_amount         double,
   status               varchar(20),
   primary key (id)
);

/*==============================================================*/
/* Table: claim_voucher_item                                    */
/*==============================================================*/
create table claim_voucher_item
(
   id                   int not null auto_increment,
   claim_voucher_id     int,
   item                 varchar(20),
   amount               double,
   comment              varchar(100),
   primary key (id)
);

/*==============================================================*/
/* Table: deal_record                                           */
/*==============================================================*/
create table deal_record
(
   id                   int not null auto_increment,
   claim_voucher_id     int,
   deal_sn              char(5),
   deal_time            datetime,
   deal_way             varchar(20),
   deal_result          varchar(20),
   comment              varchar(100),
   primary key (id)
);

/*==============================================================*/
/* Table: department                                            */
/*==============================================================*/
create table department
(
   sn                   char(5) not null,
   name                 varchar(20),
   address              varchar(100),
   primary key (sn)
);

/*==============================================================*/
/* Table: employee                                              */
/*==============================================================*/
create table employee
(
   sn                   char(5) not null,
   password             varchar(20),
   name                 varchar(20),
   department_sn        char(5),
   post                 varchar(20),
   primary key (sn)
);

alter table claim_voucher add constraint FK_Reference_2 foreign key (next_deal_sn)
      references employee (sn) on delete restrict on update restrict;

alter table claim_voucher add constraint FK_Reference_3 foreign key (create_sn)
      references employee (sn) on delete restrict on update restrict;

alter table claim_voucher_item add constraint FK_Reference_4 foreign key (claim_voucher_id)
      references claim_voucher (id) on delete restrict on update restrict;

alter table deal_record add constraint FK_Reference_5 foreign key (claim_voucher_id)
      references claim_voucher (id) on delete restrict on update restrict;

alter table deal_record add constraint FK_Reference_6 foreign key (deal_sn)
      references employee (sn) on delete restrict on update restrict;

alter table employee add constraint FK_Reference_1 foreign key (department_sn)
      references department (sn) on delete restrict on update restrict;

insert into department values('10001','总经理办公室','星星大厦E座1201');
insert into department values('10002','财务部','星星大厦E座1202');
insert into department values('10003','事业部','星星大厦E座1101');

insert into employee values('10001','000000','刘备','10001','总经理');
insert into employee values('10002','000000','孙尚香','10002','财务');
insert into employee values('10003','000000','关羽','10003','部门经理');
insert into employee values('10004','000000','周仓','10003','员工');
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值