超市pos系统的数据库设计.doc

更新时间:2023-05-04 23:32:01 阅读量: 实用文档 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

超市POS管理系统

数据库设计

数据库在一个信息管理系统中占有非常重要的地位,数据库结构的设计好坏将直接对应用系统的效率以及实现的效果产生影响。数据库设计一般包括以下四个部分:数据库需求分析、数据库概念结构设计、数据库逻辑结构设计、数据库物理结构实现。

一、数据库需求分析

通过对超市管理工作过程的内容和数据流图分析,设计如下面的数据项和数据结构。

1、员工信息,包括的数据项有:员工编号,姓名,性别,职务,口令,权限级别、身份证号,所属部门编号等。

2、部门信息,包括的数据项有:部门编号,部门名称。

3、供应商信息,包括的数据项有:供应商编号,供应商名称,地址,邮政编码,电话号码,税号,银行帐号,开户银行,联系人,备注等。

4、会员信息,包括的数据项有:会员编号,姓名,性别,身份证号,消费总金额,积分等。

5、入库信息,包括的数据项有:入库编号,入库日期,商品编号,计量单位,入库价格,销售价格,数量,总金额,供应商编号,业务员编号等。

6、商品信息,包括的数据项有:商品编号,所属类别,数量,单价,商品名称等。

7、销售出货单主信息,包括的数据项有:销售日期,总金额,是否现金,是否会员,会员编号、收银号编号等。

8、销售出货单子信息,包括的数据项有:商品编号,数量,单价,折扣比例,金额等。

二、数据库概念结构设计

根据上面设计规划出的实体,我们对各个实体具体的描述E-R图如下:

图1 员工信息E-R 图

图2 部门信息E-R 图

图3 入库信息E-R 图

图4 商品信息E-R 图

图5 销售出货单主信息E-R图

图6 销售出货单子信息E-R图

图7 会员信息E-R图

图8 供应商信息E-R图

实体与实体之间的关系E-R图:

三、数据库逻辑结构设计

四、数据库物理结构实现

根据以上的逻辑分析所得到表的关系,我们使用T-SQL语言设计得到数据库和数据表。

1.create database glxt

on

( name=pos_dat,

filename='D:\pos_dat.mdf',

size=5,

maxsize=20,

filegrowth=1)

LOG on

( name=pos_log,

filename='D:\pos_log.ldf',

size=5,

maxsize=20,

filegrowth=1)

2.create table bm

(bmbh char(8) not null

constraint PK_bno primary key,

bmmc char(4) not null

)

go

3.create table sp

(spbh char(8) not null

constraint PK_cno primary key,

spmc varchar(20) not null ,

sslb char(8) not null,

sl int not null,

jg money not null

)

go

4.create table gys

(gysbh char(8) not null

constraint PK_dno primary key,

gysmc char(8) not null,

dz varchar(20) not null,

yzbm char(8) not null,

dhhm varchar(15) not null,

sh varchar(3) not null,

yhzh varchar(20) not null,

khyh char(8) not null,

lxr char(8) not null,

beizhu text null

)

go

5.create table hy

(hybh char(8) not null

constraint PK_eno primary key,

hyname char(6)not null,

sex char(2) check CK_hy sex in (‘男’,’女’) not null, sfzh varchar(20) not null,

xfzje money not null,

jf int not null

)

Go

6.create table yg

(ygbh char(8) not null

constraint PK_fno primary key,

ygname char(8) not null,

sex char(2) check CK_yg sex in (‘男’,’女’) not null,

zw char(8) not null,

kl varchar(20) not null,

qxjb char(4) not null,

sfzh varchar(18) not null,

ssbmbh char(8) not null

constraint FK_ano foreign key references bm(bmbh) )

go

7.create table rk

(rkbh char(8) not null

constraint PK_gno primary key,

xsjg money not null,

rkrq datetime not null,

spbh char(8) not null

constraint FK_bno foreign key references sp(spbh), ywybh char(8) not null

constraint FK_cno foreign key references yg(ygbh), jldw char(2) not null,

rkjg money not null,

gysbh char(8) not null

constraint FK_dno foreign key references gys(gysbh),

zje money not null,

sl int not null

)

go

8.create table zhuxx

(xsrq datetime not null,

zje money not null,

sfxj char(2) check CK_zhuxx_sfxj in (‘是’,’否’) not null , sfhy char(2) check CK_zhuxx_sfhy in (‘是’,’否’) ,

hybh char(8) not null

constraint FK_eno foreign key references hy(hybh), syybh char(8) not null

constraint FK_fno foreign key references yg(ygbh)

)

go

9.create table zixx

( spbh char(8) not null

constraint FK_gno foreign key references sp(spbh),

sl int not null,

dj money not null,

zkbl char(10) not null,

je money not null,

)

go

10.create table kc

(kcxxbh char(8) not null

constraint PK_pno primary key,

spbh char(8) not null

constraint FK_ino foreign key references sp(spbh),

kcl int not null

)

go

五、数据库扩展功能实现

1.CREATE TRIGGER triger_sl

ON rk

after insert

AS

update kc

set kcl=kcl+(select sl from inserted)

where spbh=(select spbh from inserted)

2. CREATE TRIGGER triger_kc

ON zixx

after delete

AS

update kc

set kcl=kcl-(select sl from deleted) where spbh=(select spbh from deleted)

本文来源:https://www.bwwdw.com/article/u91e.html

Top