实验2.售后服务管理系统数据建模

该博客详细介绍了售后服务管理系统的数据建模过程,包括逻辑模型和物理模型的设计。涉及销售、服务部门、顾客、供应商等多个实体,以及合同、产品、售后服务、维修产品和维修员之间的关系。重点讨论了产品保修期判断、售后服务产品信息记录和服务工程师信息管理等问题。通过SQL代码展示了数据库表的创建和关系设置,并提供了实验环境和资源链接。

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

售后服务管理系统数据建模

逻辑模型、物理模型、SQL代码与实验报告的位置:
https://download.youkuaiyun.com/download/weixin_50836014/85970144

实验环境:
操作系统:Windows10
数据库设计软件:PowerDesigner

实验报告如下:

一.设计思路:

​ 1.该数据库设计主要设计三个主体:销售\服务部门,顾客,供应商。供应商提供产品,销售员工负责与顾客签订合同,销售员工负责向顾客提供售后服务。

​ 2.该模型中存在多个一对多的关系,如一个合同中可能包含多个合同产品,一个售后服务可能包含多个需要维修的产品,而一个产品也可能对应多个维修员。所以我在每一个父表下建立一个子表,并通过主键和外键进行约束。

​ 3.在售后服务中,每次售后服务都对应于一个合同(外键 contract_id)、一位申请服务的顾客(外键 customer_id)、一位负责对接的服务员工(外键 employee_id),当然每次售后服务都有自己的编号(主键 service_id)。每一次的售后服务都有若干需要维修的产品,每一个待维修产品的维修都有自己的维修编号(主键 service_detail_id),同时对应该产品的编号(product_id)、以及维修开始时间和结束时间、问题、解决方案。此外,每个维修产品可能需要多个维修员的参与。

二.逻辑模型

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-enh4eZEP-1657290970332)(file:///C:\Users\Hasee\AppData\Local\Temp\ksohtml1764\wps1.jpg)]

三.物理模型

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-g9VpU67n-1657290970334)(file:///C:\Users\Hasee\AppData\Local\Temp\ksohtml1764\wps2.jpg)]

四.实验问题

(1) 如何实现售后服务中的产品服务期限的?

每一个“产品”都有一个保修期(warranty_period)和生产日期(produce_date),只要对此产品申请售后服务的时间(service_start_time)在“产品”保修期内,即可向合同中的员工申请维修(phone)。

(2) 如何记录售后服务的产品信息?

每一个“合同”和“产品”都分别有一个主键contract_id和product_id,每个“合同”可能对应多个“合同产品”,所以每个“合同产品”都有contract_id和product_id两个外键。在“售后服务”中会通过contract_id的外键确定“合同”,进而确定“合同产品”,且在每个“售后服务”中可能对应维修多个“合同产品”,每个维修的合同产品记录为一个“维修产品”。

(3) 如何记录技术服务工程师(包括服务专员)的信息?

在每个“售后服务”中,都记录有接收这个服务的服务人员(一对一),每个“售后服务”可能对应多个“维修产品”,每个“维修产品”又可能对应多个“维修员”,所以我们在“维修产品”下建立了一个子表维修员,用于记录参与维修该产品的服务工程师(即维修员)。

(4) 一个完整的服务信息(如维修一个磁盘可能包括第一次打电话咨询、维修等由多个小服务组成一个大服务)是如何记录的?

​ 具体流程如下:

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-8BtANMs7-1657290970335)(file:///C:\Users\Hasee\AppData\Local\Temp\ksohtml1764\wps3.jpg)]

生成的SQL代码如下:(代码由powerDesigner自动生成导出)
/*==============================================================*/
/* DBMS name:      Microsoft SQL Server 2012                    */
/* Created on:     2021/9/9 11:19:30                            */
/*==============================================================*/


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_产品_REFERENCE_供应商')
alter table 产品
   drop constraint FK_产品_REFERENCE_供应商
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_合同_REFERENCE_销售、服务员工')
alter table 合同
   drop constraint FK_合同_REFERENCE_销售、服务员工
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_合同_REFERENCE_顾客')
alter table 合同
   drop constraint FK_合同_REFERENCE_顾客
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_合同产品_REFERENCE_合同')
alter table 合同产品
   drop constraint FK_合同产品_REFERENCE_合同
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_合同产品_REFERENCE_产品')
alter table 合同产品
   drop constraint FK_合同产品_REFERENCE_产品
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_售后服务_REFERENCE_顾客')
alter table 售后服务
   drop constraint FK_售后服务_REFERENCE_顾客
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_售后服务_REFERENCE_销售、服务员工')
alter table 售后服务
   drop constraint FK_售后服务_REFERENCE_销售、服务员工
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_售后服务_REFERENCE_合同')
alter table 售后服务
   drop constraint FK_售后服务_REFERENCE_合同
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_维修产品_REFERENCE_售后服务')
alter table 维修产品
   drop constraint FK_维修产品_REFERENCE_售后服务
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_维修员_REFERENCE_维修产品')
alter table 维修员
   drop constraint FK_维修员_REFERENCE_维修产品
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_销售、服务员工_REFERENCE_销售、服务部门')
alter table 销售、服务员工
   drop constraint FK_销售、服务员工_REFERENCE_销售、服务部门
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  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  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  sysobjects
           where  id = object_id('顾客')
            and   type = 'U')
   drop table 顾客
go

/*==============================================================*/
/* Table: 产品                                                    */
/*==============================================================*/
create table 产品 (
   product_id           varchar(15)          not null,
   vendor_id            varchar(15)          null,
   name                 varchar(50)          null,
   price                integer              null,
   warranty_period      integer              null,
   produce_date         datetime             null,
   constraint PK_产品 primary key (product_id)
)
go

/*==============================================================*/
/* Table: 供应商                                                   */
/*==============================================================*/
create table 供应商 (
   vendor_id            varchar(15)          not null,
   phone                char(11)             null,
   address              varchar(20)          null,
   name                 varchar(50)          null,
   constraint PK_供应商 primary key (vendor_id)
)
go

/*==============================================================*/
/* Table: 合同                                                    */
/*==============================================================*/
create table 合同 (
   contract_id          varchar(15)          not null,
   name                 varchar(50)          null,
   date_of_signing      datetime             null,
   business_id          varchar(15)          null,
   business_result      varchar(Max)         null,
   customer_id          varchar(15)          null,
   employee_id          varchar(15)          null,
   contract_amount      integer              null,
   constraint PK_合同 primary key (contract_id)
)
go

/*==============================================================*/
/* Table: 合同产品                                                  */
/*==============================================================*/
create table 合同产品 (
   product_id           varchar(15)          null,
   contract_id          varchar(15)          null,
   name                 varchar(50)          null,
   price                integer              null,
   amount               integer              null
)
go

/*==============================================================*/
/* Table: 售后服务                                                  */
/*==============================================================*/
create table 售后服务 (
   service_id           varchar(15)          not null,
   contract_id          varchar(15)          null,
   employee_id          varchar(15)          null,
   customer_id          varchar(15)          null,
   cuesomer_phone       char(11)             null,
   constraint PK_售后服务 primary key (service_id)
)
go

/*==============================================================*/
/* Table: 维修产品                                                  */
/*==============================================================*/
create table 维修产品 (
   service_detail_id    varchar(15)          not null,
   service_id           varchar(15)          null,
   product_id           varchar(15)          null,
   service_start_time   datetime             null,
   service_end_time     datetime             null,
   type                 varchar(50)          null,
   price                integer              null,
   problem              varchar(Max)         null,
   solution             varchar(Max)         null,
   constraint PK_维修产品 primary key (service_detail_id)
)
go

/*==============================================================*/
/* Table: 维修员                                                   */
/*==============================================================*/
create table 维修员 (
   service_detail_id    varchar(15)          null,
   employee_id          varchar(15)          null,
   employee_name        varchar(50)          null
)
go

/*==============================================================*/
/* Table: 销售、服务员工                                               */
/*==============================================================*/
create table 销售、服务员工 (
   employee_id          varchar(15)          not null,
   department_id        varchar(15)          null,
   name                 varchar(50)          null,
   phone                char(11)             null,
   constraint PK_销售、服务员工 primary key (employee_id)
)
go

/*==============================================================*/
/* Table: 销售、服务部门                                               */
/*==============================================================*/
create table 销售、服务部门 (
   department_id        varchar(15)          not null,
   address              varchar(50)          null,
   constraint PK_销售、服务部门 primary key (department_id)
)
go

/*==============================================================*/
/* Table: 顾客                                                    */
/*==============================================================*/
create table 顾客 (
   customer_id          varchar(15)          not null,
   bank_account         varchar(15)          null,
   credit               varchar(15)          null,
   phone                char(11)             null,
   name                 varchar(50)          null,
   constraint PK_顾客 primary key (customer_id)
)
go

alter table 产品
   add constraint FK_产品_REFERENCE_供应商 foreign key (vendor_id)
      references 供应商 (vendor_id)
go

alter table 合同
   add constraint FK_合同_REFERENCE_销售、服务员工 foreign key (employee_id)
      references 销售、服务员工 (employee_id)
go

alter table 合同
   add constraint FK_合同_REFERENCE_顾客 foreign key (customer_id)
      references 顾客 (customer_id)
go

alter table 合同产品
   add constraint FK_合同产品_REFERENCE_合同 foreign key (contract_id)
      references 合同 (contract_id)
go

alter table 合同产品
   add constraint FK_合同产品_REFERENCE_产品 foreign key (product_id)
      references 产品 (product_id)
go

alter table 售后服务
   add constraint FK_售后服务_REFERENCE_顾客 foreign key (customer_id)
      references 顾客 (customer_id)
go

alter table 售后服务
   add constraint FK_售后服务_REFERENCE_销售、服务员工 foreign key (employee_id)
      references 销售、服务员工 (employee_id)
go

alter table 售后服务
   add constraint FK_售后服务_REFERENCE_合同 foreign key (contract_id)
      references 合同 (contract_id)
go

alter table 维修产品
   add constraint FK_维修产品_REFERENCE_售后服务 foreign key (service_id)
      references 售后服务 (service_id)
go

alter table 维修员
   add constraint FK_维修员_REFERENCE_维修产品 foreign key (service_detail_id)
      references 维修产品 (service_detail_id)
go

alter table 销售、服务员工
   add constraint FK_销售、服务员工_REFERENCE_销售、服务部门 foreign key (department_id)
      references 销售、服务部门 (department_id)
go



更多资源

北京理工大学—计算机专业课程资源https://blog.youkuaiyun.com/weixin_50836014/article/details/125687455

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一只野指针.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值