前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【数据库设计】宠物商店管理系统

【数据库设计】宠物商店管理系统

作者头像
SarPro
发布2024-06-14 13:01:46
780
发布2024-06-14 13:01:46
举报
文章被收录于专栏:【计网】Cisco【计网】Cisco
🌊1 问题的提出

随着中国经济的增长,宠物行业得到了迅猛的发展,人们饲养宠物已经由单纯的赏玩而转变成人们精神的一种寄托,宠物的角色也悄然发生着变化,已经日益成为人们生活的伴侣,在促进和谐社会发挥着不可替代的调节作用,越来越多的人开始养宠物,其中以猫狗为主。由于市场的无序竞争,法制观念淡,数量大但精品少,管理不规范加上缺少相关法律法规和行业标准的监管和约束,导致当前我国宠物用品竞争无序,尚未形成高水平的专业大市场,严重的影响了宠物用品行业的健康发展。同时,宠物用品网购企业受销售规模所限,渠道谈判力量较弱,货源大多被品牌渠道商控制。而渠道供应商方面可能存在掺杂假货等不规范操作,容易造成产品质量问题,这会对消费者权益造成一定损害,也对网购企业的品牌有所不利。而我国目前没有网络购物的法律规范,消费者维权时常遭遇无法可依的尴尬。而无良商家也经常利用法律法规的漏洞,制定霸王条款,侵犯消费者权益。

宠物商店管理系统是基于大多数宠物主囿于宠物商店市场不规范的现状进行的一次改造探索与创新。该系统集“宠物商店”与“其他促进宠物健康的增值服务”(如预约服务、宠物选择、宠物商品的售卖等)于一体。在保障上:针对顾客体验宠物商店过程中的不规范以及责任纠纷问题,为用户提供了可供参考的宠物商店服务(平台提供了不同的宠物类别,用户可根据自己需求选择性购买);在渠道上:扮演宠物商店的中介角色,提供线上新渠道,不仅能够帮助宠物主减少宠物商店忧虑、为自己找到合适的宠物以及相应的宠物服务,还通过增值服务抓住了与此相关前后的宠物服务市场,在此基础上宠物商店管理系统应运而生。


🌊2 需求分析

🌍2.1 系统目的

本宠物商店管理系统从致力从宠物商店的视角出发,提供规范化的宠物商店服务。宠物商店管理系统聚焦于一、二线城市的中青年群体的宠物商店诉求,为青年选择宠物、帮助宠物主降低忧虑、对规范宠物相亲市场具有极大的推动意义。宠物商店市场开发潜力巨大,如果对宠物商店市场进行有效开发和运营,可以有效推动经济增长和解决就业问题,为宠物行业不规范的问题提供可借鉴的解决办法。


🌍2.2 用户需求
🌻2.2.1 我国宠物行业作为新兴市场,潜力巨大

随着社会的发展,在物质生活极大丰富的同时,人们对于精神生活的追求也到了一定的高度。一方面,人们越来越注重培养生活情趣和追求个性化体验,另一方面,传统家庭结构的改变和工作压力的增大,使越来越多的人将感情投注于宠物身上,宠物行业由此逐渐发展起来。根据《2020年中国宠物行业白皮书》显示,我国宠物数量及养宠人数持续增长,2020年中国犬、猫数量已突破1亿只,养犬猫人数达到6294万人,增幅为2.80%。2020年我国宠物经济规模已经接近3000亿元,并在未来三年保持约14.20%的年复合增长率。


🌻2.2.2 我国宠物产品消费规模逐年增大

在生活节奏越来越快的当下,人与人之间交流变少带来的孤独感,导致越来越多人视宠物为自己最亲密的伙伴。有超九成的宠物主表示视宠物为家人、朋友甚至伴侣,宠物家庭属性进一步加强。


🌻2.2.3 我国宠物主选择高端产品和服务的意愿日渐显著

从消费结构来看,食品市场份额降低,服务市场份额增加。而且在2020年宠物诊疗支出达334.53亿元,同比增长65.30%,这项消费支出增长最快。由此可见,人们对宠物更高品质服务的需求在逐渐增加。

宠物的家庭地位日渐攀升,宠物主为爱宠花钱的意愿愈发强烈,宠物消费领域将迎来整体升级。宠物主人收入水平和消费能力的提升,宠物主人在宠物身上的投入也在持续增加。《2019年中国宠物行业白皮书》显示,2019年中国城镇宠物犬猫消费市场规模已达到2024亿元,比2018年增长18.5%。其中宠物犬消费市场规模为1244亿元,比2018年增长17.8%;宠物猫消费市场规模为780亿元,增幅达19.6%,超过犬消费市场规模增速。宠物行业仍是目前少有的市场规模庞大,且维持高速增长的潜力行业。

根据《2020年宠物行业白皮书》公布的数据显示,2020年我国宠物(猫狗)消费市场规模达2065亿元,同比增长2.00%,其中宠物狗消费市场规模为1180亿元,较2019年下降5.10%,宠物猫消费市场规模为884亿元,同比增长13.30%

从宠物客单价不同价格段的消费人数分布来看,高消费人群占比约20.00%,且高价格段的消费人数增速突出,这足以说明,随着宠物家庭地位的攀升,主人们相较过去更愿为宠物一掷千金,宠物行业高端化产品和服务的前景巨大。

宠物消费的“恩格尔系数”在降低。《2021年中国宠物行业白皮书》显示,从2019年到2021年,食品的市场份额从61.40%降低到51.50%,下降接近10个百分点。医疗的市场份额从19.00%到29.20%,增加了10个百分点。从消费结构来看,食品市场份额降低,服务市场份额增加。而且从更细分的市场来看,诊疗市场的份额达到14.60%,成为仅次于主粮的第二大细分市场。而且在2020年宠物诊疗支出达334.53亿元,同比增长65.30%,这项消费支出增长最快。由此可见,人们对宠物更高品质服务的需求在逐渐增加。


🌍2.3 数据流图

数据流图这块一共分为三级,第一级在全局层面表明顾客、宠物商店管理系统以及销售员三者之间的联系;第二级将宠物商店管理系统细分为预约、进店两块,将预约记录、商品信息、宠物信息、预期消费记录、选择结果、收费标准以及交易记录与预约和进店进行信息交互;第三级分别是预约和进店的细分,具体流程见以下数据流图。

🌻2.3.1 第一级数据流图:

🌻2.3.2 第二级数据流图:

🌻2.3.3 第三级数据流图:

第三级数据流图之预约块:

第三级数据流图之进店块:


🌍2.4 数据字典

由于Power Designer针对物理模型导出的数据字典较多,这里主要选其中的主要清单与卡片进行展示。


🌻2.4.1 表格清单

名称

代码

交易记录

交易记录

发票

发票

宠物信息

宠物信息

宠物用品

宠物用品

收费标准

收费标准

营销部

营销部

选择结果

选择结果

销售员

销售员

顾客

顾客

预约单

预约单


🌻2.4.2 参考清单

名称

代码

父表格

子表格

外键列

父角色

子角色

了解

了解

顾客

宠物信息

顾客号; 预约号

做出

做出

选择结果

顾客

商品号; 选择结_顾客号

包含

包含

发票

宠物信息

发票号

包括

包括

发票

宠物用品

发票号

参照

参照

收费标准

交易记录

商品号; 单价

参考

参考

收费标准

预约单

商品号; 单价

反馈

反馈

销售员

选择结果

销售员号

填写

填写

销售员

发票

销售员_销售员号

属于

属于

营销部

销售员

销售部号

持有

持有

顾客

预约单

顾客_顾客号; 顾客_预约号

接受

接受

销售员

预约单

销售员_销售员号

提供

提供

销售员

宠物信息

销售员号

查看

查看

顾客

宠物用品

顾客号; 预约号

申请

申请2

发票

顾客

发票号

申请

申请

顾客

发票

顾客_顾客号; 预约号

给出

给出

销售员

宠物用品

销售员号

缴费

缴费2

交易记录

发票

交易号

缴费

缴费

发票

交易记录

发票号


🌻2.4.3 表格宠物信息的输出参考清单

名称

代码

父表格

外键列

父角色

子角色

了解

了解

顾客

顾客号; 预约号

包含

包含

发票

发票号

提供

提供

销售员

销售员号


🌻2.4.4 表格宠物信息的列清单

名称

代码

数据类型

长度

主要的

宠物号

宠物号

varchar(20)

20

TRUE

销售员号

销售员号

varchar(10)

10

FALSE

顾客号

顾客号

varchar(10)

10

FALSE

预约号

预约号

varchar(20)

20

FALSE

发票号

发票号

varchar(10)

10

FALSE

宠物姓名

宠物姓名

varchar(20)

20

FALSE

宠物品种

宠物品种

varchar(20)

20

FALSE

宠物出生日期

宠物出生日期

datetime

FALSE

宠物价格

宠物价格

real

FALSE

宠物健康状态

宠物健康状态

varchar(10)

10

FALSE


🌻2.4.5 表格宠物信息的索引清单

名称

代码

唯一的

群集器

主要的

外键

候选键

表格

宠物信息_PK

宠物信息_PK

TRUE

FALSE

TRUE

FALSE

FALSE

宠物信息

了解_FK

了解_FK

FALSE

FALSE

FALSE

TRUE

FALSE

宠物信息

提供_FK

提供_FK

FALSE

FALSE

FALSE

TRUE

FALSE

宠物信息

包含_FK

包含_FK

FALSE

FALSE

FALSE

TRUE

FALSE

宠物信息


🌻2.4.6 表格宠物信息的键清单

名称

代码

主要的

Identifier_1

Identifier_1

TRUE


🌊3 数据库三个设计步骤

🌍3.1 概念设计

将需求分析阶段所得到的应用需求抽象为信息世界的结构,真实、充分地反映现实世界,这里主要采用Power Designer建立概念模型CDM文件生成的概念模型图进行现实世界概念模型的描述,包括实体、属性、实体之间的联系等,以下给定的是总概念模型,并且运用表格法对以下关系数据库中的关系进行模式分解,使其关系模式达到三范式。


🌍3.2 逻辑设计

将概念结构设计阶段的概念模型图转变为PDM文件生成的物理模型图,具体信息如下。


🌍3.3 物理设计

本次设计采用SQL SERVER的默认物理设计。


🌊4 数据库和其他数据库对象的实现

🌍4.1 表

采用SQL SERVER建立“宠物商店管理系统”数据库,其中表有宠物信息、宠物用品、发票、顾客、销售员、营销部、交易记录、收费标准、选择结果、预约单十张表。


🌍4.2 视图

🌍4.3 数据库关系图

🌍4.4 索引

🌍4.5 存储过程

🌍​​​​​​​4.6 函数

🌊5 测试与运行实例

在宠物商店管理系统的基础上,以微信小程序的方式建立起“宠伴驿站”的线上宠物购物平台,其中页面主要有以下,主要分为相亲角、分类、社区、购物车以及个人页面:

宠物主可以在“相亲角”板块为自己宠物寻找相亲对象,“相亲角”将会显示发布了“征婚信息”的宠物相关介绍,宠物主可以自主选择;也可以在页面上方的搜索栏直接输入心仪的相亲品种或宠物星级。

“相亲角”页面:

“宠物商品分类”页面:

“商品详情”页面:

“社区”页面:

“购物车”页面:

我的”页面:

“意见反馈”页面:


🌊结论

本次宠物商店管理系统的概念设计、逻辑设计以及物理设计主要建立在Power Designer数据库设计工具和SQL Server数据库管理系统,使用数据库设计工具绘制数据流图,建立概念模型和物理模型,最终生成数据库和表及其他数据库对象,建立起合理高性能的数据库系统,并且运用微信开发者工具与vscode相结合的开发方式对宠物商店管理系统进行外观设计和功能设计,实现基本功能的同时满足用户的良好体验。尽管设计过程中不断会冒出大大小小的问题,但我始终坚信虚壹而静,静心而行,每解决一个问题,我都会像个孩子般高兴的手舞足蹈,正是在这段埋头苦干时常熬夜的日子里,我也在不断的成长着。


🌊参考文献

1 王珊.数据仓库技术与联机分析处理.数据库技术丛书之一.[A]北京:科学出版社,1998.

2 萨师煊.数据库系统概论(第五版).[A]北京:高等教育出版社,2014(5):215-218.

3 中国畜牧业协会宠物产业分会.2019年中国宠物行业白皮书(2019年)[R].(2019-01).

4 中国畜牧业协会宠物产业分会.2020年中国宠物行业白皮书(2020年)[R].(2020-01).

5 中国畜牧业协会宠物产业分会.2021年中国宠物行业白皮书(2021年)[R].(2021-01).


🌊附录 TSQL语句

Tsql语句如下:

代码语言:javascript
复制
/*==============================================================*/

/* DBMS name:      Microsoft SQL Server 2008                    */

/* Created on:     2022/5/23 14:09:27                           */

/*==============================================================*/





if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('交易记录') and o.name = 'FK_交易记录_参照_收费标准')

alter table 交易记录

   drop constraint FK_交易记录_参照_收费标准

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('交易记录') and o.name = 'FK_交易记录_缴费_发票')

alter table 交易记录

   drop constraint FK_交易记录_缴费_发票

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('发票') and o.name = 'FK_发票_填写_销售员')

alter table 发票

   drop constraint FK_发票_填写_销售员

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('发票') and o.name = 'FK_发票_申请_顾客')

alter table 发票

   drop constraint FK_发票_申请_顾客

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('发票') and o.name = 'FK_发票_缴费2_交易记录')

alter table 发票

   drop constraint FK_发票_缴费2_交易记录

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('宠物信息') and o.name = 'FK_宠物信息_了解_顾客')

alter table 宠物信息

   drop constraint FK_宠物信息_了解_顾客

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('宠物信息') and o.name = 'FK_宠物信息_包含_发票')

alter table 宠物信息

   drop constraint FK_宠物信息_包含_发票

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('宠物信息') and o.name = 'FK_宠物信息_提供_销售员')

alter table 宠物信息

   drop constraint FK_宠物信息_提供_销售员

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('宠物用品') and o.name = 'FK_宠物用品_包括_发票')

alter table 宠物用品

   drop constraint FK_宠物用品_包括_发票

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('宠物用品') and o.name = 'FK_宠物用品_查看_顾客')

alter table 宠物用品

   drop constraint FK_宠物用品_查看_顾客

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('宠物用品') and o.name = 'FK_宠物用品_给出_销售员')

alter table 宠物用品

   drop constraint FK_宠物用品_给出_销售员

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('选择结果') and o.name = 'FK_选择结果_反馈_销售员')

alter table 选择结果

   drop constraint FK_选择结果_反馈_销售员

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('销售员') and o.name = 'FK_销售员_属于_营销部')

alter table 销售员

   drop constraint FK_销售员_属于_营销部

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('顾客') and o.name = 'FK_顾客_做出_选择结果')

alter table 顾客

   drop constraint FK_顾客_做出_选择结果

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('顾客') and o.name = 'FK_顾客_申请2_发票')

alter table 顾客

   drop constraint FK_顾客_申请2_发票

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('预约单') and o.name = 'FK_预约单_参考_收费标准')

alter table 预约单

   drop constraint FK_预约单_参考_收费标准

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('预约单') and o.name = 'FK_预约单_持有_顾客')

alter table 预约单

   drop constraint FK_预约单_持有_顾客

go



if exists (select 1

   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

   where r.fkeyid = object_id('预约单') and o.name = 'FK_预约单_接受_销售员')

alter table 预约单

   drop constraint FK_预约单_接受_销售员

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('交易记录')

            and   name  = '缴费_FK'

            and   indid > 0

            and   indid < 255)

   drop index 交易记录.缴费_FK

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('交易记录')

            and   name  = '参照_FK'

            and   indid > 0

            and   indid < 255)

   drop index 交易记录.参照_FK

go



if exists (select 1

            from  sysobjects

           where  id = object_id('交易记录')

            and   type = 'U')

   drop table 交易记录

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('发票')

            and   name  = '缴费2_FK'

            and   indid > 0

            and   indid < 255)

   drop index 发票.缴费2_FK

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('发票')

            and   name  = '申请_FK'

            and   indid > 0

            and   indid < 255)

   drop index 发票.申请_FK

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('发票')

            and   name  = '填写_FK'

            and   indid > 0

            and   indid < 255)

   drop index 发票.填写_FK

go



if exists (select 1

            from  sysobjects

           where  id = object_id('发票')

            and   type = 'U')

   drop table 发票

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('宠物信息')

            and   name  = '包含_FK'

            and   indid > 0

            and   indid < 255)

   drop index 宠物信息.包含_FK

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('宠物信息')

            and   name  = '提供_FK'

            and   indid > 0

            and   indid < 255)

   drop index 宠物信息.提供_FK

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('宠物信息')

            and   name  = '了解_FK'

            and   indid > 0

            and   indid < 255)

   drop index 宠物信息.了解_FK

go



if exists (select 1

            from  sysobjects

           where  id = object_id('宠物信息')

            and   type = 'U')

   drop table 宠物信息

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('宠物用品')

            and   name  = '包括_FK'

            and   indid > 0

            and   indid < 255)

   drop index 宠物用品.包括_FK

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('宠物用品')

            and   name  = '查看_FK'

            and   indid > 0

            and   indid < 255)

   drop index 宠物用品.查看_FK

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('宠物用品')

            and   name  = '给出_FK'

            and   indid > 0

            and   indid < 255)

   drop index 宠物用品.给出_FK

go



if exists (select 1

            from  sysobjects

           where  id = object_id('宠物用品')

            and   type = 'U')

   drop table 宠物用品

go



if exists (select 1

            from  sysobjects

           where  id = object_id('收费标准')

            and   type = 'U')

   drop table 收费标准

go



if exists (select 1

            from  sysobjects

           where  id = object_id('营销部')

            and   type = 'U')

   drop table 营销部

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('选择结果')

            and   name  = '反馈_FK'

            and   indid > 0

            and   indid < 255)

   drop index 选择结果.反馈_FK

go



if exists (select 1

            from  sysobjects

           where  id = object_id('选择结果')

            and   type = 'U')

   drop table 选择结果

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('销售员')

            and   name  = '属于_FK'

            and   indid > 0

            and   indid < 255)

   drop index 销售员.属于_FK

go



if exists (select 1

            from  sysobjects

           where  id = object_id('销售员')

            and   type = 'U')

   drop table 销售员

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('顾客')

            and   name  = '申请2_FK'

            and   indid > 0

            and   indid < 255)

   drop index 顾客.申请2_FK

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('顾客')

            and   name  = '做出_FK'

            and   indid > 0

            and   indid < 255)

   drop index 顾客.做出_FK

go



if exists (select 1

            from  sysobjects

           where  id = object_id('顾客')

            and   type = 'U')

   drop table 顾客

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('预约单')

            and   name  = '持有_FK'

            and   indid > 0

            and   indid < 255)

   drop index 预约单.持有_FK

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('预约单')

            and   name  = '接受_FK'

            and   indid > 0

            and   indid < 255)

   drop index 预约单.接受_FK

go



if exists (select 1

            from  sysindexes

           where  id    = object_id('预约单')

            and   name  = '参考_FK'

            and   indid > 0

            and   indid < 255)

   drop index 预约单.参考_FK

go



if exists (select 1

            from  sysobjects

           where  id = object_id('预约单')

            and   type = 'U')

   drop table 预约单

go



/*==============================================================*/

/* Table: 交易记录                                                  */

/*==============================================================*/

create table 交易记录 (

   交易号                  varchar(10)          not null,

   商品号                  varchar(10)          null,

   单价                   real                 null,

   发票号                  varchar(10)          null,

   交易金额                 real                 null,

   顾客号                  varchar(10)          null,

   销售员号                 varchar(10)          null,

   交易日期                 datetime             null,

   constraint PK_交易记录 primary key nonclustered (交易号)

)

go



/*==============================================================*/

/* Index: 参照_FK                                                 */

/*==============================================================*/

create index 参照_FK on 交易记录 (

商品号 ASC,

单价 ASC

)

go



/*==============================================================*/

/* Index: 缴费_FK                                                 */

/*==============================================================*/

create index 缴费_FK on 交易记录 (

发票号 ASC

)

go



/*==============================================================*/

/* Table: 发票                                                    */

/*==============================================================*/

create table 发票 (

   发票号                  varchar(10)          not null,

   顾客_顾客号               varchar(10)          null,

   预约号                  varchar(20)          null,

   交易号                  varchar(10)          null,

   销售员_销售员号             varchar(10)          null,

   顾客号                  varchar(10)          null,

   数量                   int                  null,

   单价                   real                 null,

   日期                   datetime             null,

   商品名称                 varchar(10)          null,

   票头                   varchar(10)          null,

   销售员号                 varchar(10)          null,

   顾客名称                 varchar(10)          null,

   缴费金额                 real                 null,

   constraint PK_发票 primary key nonclustered (发票号)

)

go



/*==============================================================*/

/* Index: 填写_FK                                                 */

/*==============================================================*/

create index 填写_FK on 发票 (

销售员_销售员号 ASC

)

go



/*==============================================================*/

/* Index: 申请_FK                                                 */

/*==============================================================*/

create index 申请_FK on 发票 (

顾客_顾客号 ASC,

预约号 ASC

)

go



/*==============================================================*/

/* Index: 缴费2_FK                                                */

/*==============================================================*/

create index 缴费2_FK on 发票 (

交易号 ASC

)

go



/*==============================================================*/

/* Table: 宠物信息                                                  */

/*==============================================================*/

create table 宠物信息 (

   宠物号                  varchar(20)          not null,

   销售员号                 varchar(10)          null,

   顾客号                  varchar(10)          null,

   预约号                  varchar(20)          null,

   发票号                  varchar(10)          null,

   宠物姓名                 varchar(20)          null,

   宠物品种                 varchar(20)          null,

   宠物出生日期               datetime             null,

   宠物价格                 real                 null,

   宠物健康状态               varchar(10)          null,

   constraint PK_宠物信息 primary key nonclustered (宠物号)

)

go





/*==============================================================*/

/* Index: 了解_FK                                                 */

/*==============================================================*/

create index 了解_FK on 宠物信息 (

顾客号 ASC,

预约号 ASC

)

go



/*==============================================================*/

/* Index: 提供_FK                                                 */

/*==============================================================*/

create index 提供_FK on 宠物信息 (

销售员号 ASC

)

go



/*==============================================================*/

/* Index: 包含_FK                                                 */

/*==============================================================*/

create index 包含_FK on 宠物信息 (

发票号 ASC

)

go



/*==============================================================*/

/* Table: 宠物用品                                                  */

/*==============================================================*/

create table 宠物用品 (

   商品号                  varchar(10)          not null,

   销售员号                 varchar(10)          null,

   发票号                  varchar(10)          null,

   顾客号                  varchar(10)          null,

   预约号                  varchar(20)          null,

   单价                   real                 null,

   会员价                  real                 null,

   是否限购                 smallint             null,

   constraint PK_宠物用品 primary key nonclustered (商品号)

)

go



/*==============================================================*/

/* Index: 给出_FK                                                 */

/*==============================================================*/

create index 给出_FK on 宠物用品 (

销售员号 ASC

)

go



/*==============================================================*/

/* Index: 查看_FK                                                 */

/*==============================================================*/

create index 查看_FK on 宠物用品 (

顾客号 ASC,

预约号 ASC

)

go



/*==============================================================*/

/* Index: 包括_FK                                                 */

/*==============================================================*/

create index 包括_FK on 宠物用品 (

发票号 ASC

)

go



/*==============================================================*/

/* Table: 收费标准                                                  */

/*==============================================================*/

create table 收费标准 (

   商品号                  varchar(10)          not null,

   单价                   real                 not null,

   会员价                  real                 null,

   是否限购                 smallint             null,

   折扣日期                 datetime             null,

   constraint PK_收费标准 primary key nonclustered (商品号, 单价)

)

go



/*==============================================================*/

/* Table: 营销部                                                   */

/*==============================================================*/

create table 营销部 (

   销售部号                 varchar(10)          not null,

   销售主管号                varchar(10)          null,

   销售主管名                varchar(10)          null,

   销售主管性别               varchar(2)           null,

   销售主管年龄               int                  null,

   销售部人数                int                  null,

   销售月季总金额              real                 null,

   销售季总金额               real                 null,

   销售年总金额               real                 null,

   constraint PK_营销部 primary key nonclustered (销售部号)

)

go



/*==============================================================*/

/* Table: 选择结果                                                  */

/*==============================================================*/

create table 选择结果 (

   商品号                  varchar(10)          not null,

   顾客号                  varchar(10)          not null,

   销售员号                 varchar(10)          null,

   商品名称                 varchar(10)          null,

   选择日期                 datetime             null,

   总价                   real                 null,

   constraint PK_选择结果 primary key nonclustered (商品号, 顾客号)

)

go



/*==============================================================*/

/* Index: 反馈_FK                                                 */

/*==============================================================*/

create index 反馈_FK on 选择结果 (

销售员号 ASC

)

go



/*==============================================================*/

/* Table: 销售员                                                   */

/*==============================================================*/

create table 销售员 (

   销售员号                 varchar(10)          not null,

   销售部号                 varchar(10)          null,

   销售员姓名                varchar(10)          null,

   销售员性别                varchar(2)           null,

   销售员工龄                smallint             null,

   constraint PK_销售员 primary key nonclustered (销售员号)

)

go



/*==============================================================*/

/* Index: 属于_FK                                                 */

/*==============================================================*/

create index 属于_FK on 销售员 (

销售部号 ASC

)

go



/*==============================================================*/

/* Table: 顾客                                                    */

/*==============================================================*/

create table 顾客 (

   预约号                  varchar(20)          not null,

   顾客号                  varchar(10)          not null,

   发票号                  varchar(10)          null,

   商品号                  varchar(10)          null,

   选择结_顾客号              varchar(10)          null,

   顾客姓名                 varchar(20)          null,

   性别                   varchar(2)           null,

   顾客选择                 varchar(10)          null,

   会员                   smallint             null,

   顾客预算                 real                 null,

   constraint PK_顾客 primary key nonclustered (顾客号, 预约号)

)

go



/*==============================================================*/

/* Index: 做出_FK                                                 */

/*==============================================================*/

create index 做出_FK on 顾客 (

商品号 ASC,

选择结_顾客号 ASC

)

go



/*==============================================================*/

/* Index: 申请2_FK                                                */

/*==============================================================*/

create index 申请2_FK on 顾客 (

发票号 ASC

)

go



/*==============================================================*/

/* Table: 预约单                                                   */

/*==============================================================*/

create table 预约单 (

   预约号                  varchar(10)          not null,

   商品号                  varchar(10)          null,

   单价                   real                 null,

   顾客_顾客号               varchar(10)          null,

   顾客_预约号               varchar(20)          null,

   销售员_销售员号             varchar(10)          null,

   顾客号                  varchar(10)          null,

   销售员号                 varchar(10)          null,

   预约日期                 datetime             null,

   顾客预算                 real                 null,

   顾客选择                 varchar(10)          null,

   是否会员                 smallint             null,

   顾客姓名                 varchar(10)          null,

   销售员姓名                varchar(10)          null,

   constraint PK_预约单 primary key nonclustered (预约号)

)

go



/*==============================================================*/

/* Index: 参考_FK                                                 */

/*==============================================================*/

create index 参考_FK on 预约单 (

商品号 ASC,

单价 ASC

)

go



/*==============================================================*/

/* Index: 接受_FK                                                 */

/*==============================================================*/

create index 接受_FK on 预约单 (

销售员_销售员号 ASC

)

go



/*==============================================================*/

/* Index: 持有_FK                                                 */

/*==============================================================*/

create index 持有_FK on 预约单 (

顾客_顾客号 ASC,

顾客_预约号 ASC

)

Go



alter table 交易记录

   add constraint FK_交易记录_参照_收费标准 foreign key (商品号, 单价)

      references 收费标准 (商品号, 单价)

go



alter table 交易记录

   add constraint FK_交易记录_缴费_发票 foreign key (发票号)

      references 发票 (发票号)

go



alter table 发票

   add constraint FK_发票_填写_销售员 foreign key (销售员_销售员号)

      references 销售员 (销售员号)

go



alter table 发票

   add constraint FK_发票_申请_顾客 foreign key (顾客_顾客号, 预约号)

      references 顾客 (顾客号, 预约号)

go



alter table 发票

   add constraint FK_发票_缴费2_交易记录 foreign key (交易号)

      references 交易记录 (交易号)

go



alter table 宠物信息

   add constraint FK_宠物信息_了解_顾客 foreign key (顾客号, 预约号)

      references 顾客 (顾客号, 预约号)

go



alter table 宠物信息

   add constraint FK_宠物信息_包含_发票 foreign key (发票号)

      references 发票 (发票号)

go



alter table 宠物信息

   add constraint FK_宠物信息_提供_销售员 foreign key (销售员号)

      references 销售员 (销售员号)

go



alter table 宠物用品

   add constraint FK_宠物用品_包括_发票 foreign key (发票号)

      references 发票 (发票号)

go



alter table 宠物用品

   add constraint FK_宠物用品_查看_顾客 foreign key (顾客号, 预约号)

      references 顾客 (顾客号, 预约号)

go



alter table 宠物用品

   add constraint FK_宠物用品_给出_销售员 foreign key (销售员号)

      references 销售员 (销售员号)

go



alter table 选择结果

   add constraint FK_选择结果_反馈_销售员 foreign key (销售员号)

      references 销售员 (销售员号)

go



alter table 销售员

   add constraint FK_销售员_属于_营销部 foreign key (销售部号)

      references 营销部 (销售部号)

go



alter table 顾客

   add constraint FK_顾客_做出_选择结果 foreign key (商品号, 选择结_顾客号)

      references 选择结果 (商品号, 顾客号)

go



alter table 顾客

   add constraint FK_顾客_申请2_发票 foreign key (发票号)

      references 发票 (发票号)

go



alter table 预约单

   add constraint FK_预约单_参考_收费标准 foreign key (商品号, 单价)

      references 收费标准 (商品号, 单价)

go



alter table 预约单

   add constraint FK_预约单_持有_顾客 foreign key (顾客_顾客号, 顾客_预约号)

      references 顾客 (顾客号, 预约号)

go



alter table 预约单

   add constraint FK_预约单_接受_销售员 foreign key (销售员_销售员号)

      references 销售员 (销售员号)

go
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-06-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 🌊2 需求分析
    • 🌍2.1 系统目的
      • 🌍2.2 用户需求
        • 🌻2.2.1 我国宠物行业作为新兴市场,潜力巨大
        • 🌻2.2.2 我国宠物产品消费规模逐年增大
        • 🌻2.2.3 我国宠物主选择高端产品和服务的意愿日渐显著
      • 🌍2.3 数据流图
        • 🌻2.3.1 第一级数据流图:
        • 🌻2.3.2 第二级数据流图:
        • 🌻2.3.3 第三级数据流图:
      • 🌍2.4 数据字典
        • 🌻2.4.1 表格清单
        • 🌻2.4.2 参考清单
        • 🌻2.4.3 表格宠物信息的输出参考清单
        • 🌻2.4.4 表格宠物信息的列清单
        • 🌻2.4.5 表格宠物信息的索引清单
        • 🌻2.4.6 表格宠物信息的键清单
    • 🌊3 数据库三个设计步骤
      • 🌍3.1 概念设计
        • 🌍3.2 逻辑设计
          • 🌍3.3 物理设计
          • 🌊4 数据库和其他数据库对象的实现
            • 🌍4.1 表
              • 🌍4.2 视图
                • 🌍4.3 数据库关系图
                  • 🌍4.4 索引
                    • 🌍4.5 存储过程
                      • 🌍​​​​​​​4.6 函数
                      • 🌊5 测试与运行实例
                      • 🌊结论
                      • 🌊参考文献
                      • 🌊附录 TSQL语句
                      相关产品与服务
                      云数据库 SQL Server
                      腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
                      领券
                      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档