4.2数据库实施阶段任务 4.2.1建立数据库
Create database 采购管理系统;
4.2.2建立数据表
(1)需求计划单表基本信息的建立 Create table 需求计划单表
( Xno char(50) primary key Cno char(50) ,not null, Bno char(50) ,not null, Bname char(50) ,not null, Breason char(50) ,not null, )
(2) 采购计划单表基本信息的建立 Create table 采购计划单表 ( Cno char(10) primary key, Bno char(12) not null, Bname char(50) not null, Breaultchar(100) not null, )
(3) 订单表基本信息的建立 Create table 订单
( Dno char(10) primary key, Cno char(10) not null, Scode char(12) not null, Sno char(10) not null,
Sremark char(100) not null,
)
(4) 供货商表基本信息的建立 Create table 供应商表
( Gno char(10) primary key, Gname char(10) not null, Gaddress char(10) not null, Gphone char(30) not null
not null,
)
(5) 部门表基本信息的建立 Create table 部门信息表 ( Bno char(10) , Bname char(50),
Badministrator char(50) not null, Bphone char(50) not null, Beamil char(50) not null, )
4.3 建立视图
(1) 查询需求计划单表的基本信息的视图定义如下: create view 需求计划单表_view as
select *
from 需求计划单表 with check option;
(2) 查询采购计划单表的基本信息的视图定义如下:
create view 采购计划单表_view as
select *
from 采购计划单表 with check option;
(3) 查询订单表表的基本信息的视图定义如下:
create view 订单表表_view as
select *
from 订单表表 with check option;
(4) 查询供货商表的基本信息的视图定义如下: create view 供货商表_view as
select *
from 供货商表 with check option;
(5) 查询部门表的基本信息的视图定义如下:
create view 部门表_view as
select *
from 部门表 with check option;
5 存储过程定义
(1)Create procedure 需求计划单表_insert @Xno char(50), @Cno char(50), @Bno char(50), @Bname char(50), @Breason char(50), As
Insert into需求计划单表 values(@Xno,@Cno,@Bno,@Bname,@Breason); (2) create procedure 采购计划单表_insert @Cno char(10), @Bno char(12),
@Bname char(50), @Breault char(150) As
Insert into 采购计划单表 values(@Cno ,@Bno ,@Bname ,@Breault ); (3) create procedure 订单表_insert @Dno char(10), @Cno char(10), @Scode char(12), @Sno char(10),
@Sremark char(100), As
Insert into 订单表 values(@Dno ,@Cno,@Scode ,@Sno ,@Sremark, )
(4) create procedure 供应商表_insert @Sno char(10), @Sname char(10), @Sguige char(10),
@Sshengchandi char(10) @Sshuliang char(10) @Gno char(10) As
Insert into 供货商表
values(@Sno,@Sname ,@Sguige ,@Sshengchandi ,@Sshuliang,@Gno);
(5) create procedure 供货商表_insert
@Bno char(10),@Bname char(10),@Badministrator char(10),@Bphone,@Beamil As Insert into 供货商表 values(@Bno,@Bname,@Badministrator,@Bphone,@Beamil);
第六章 数据库的实施与运行
1建立数据库(教学管理系统数据库)
2基于数据表的数据查询(系表查询) (需求计划单表查询)
(采购计划单表查询)
(订单表查询)
(供货商表查询)