当前位置:网站首页>实验2.售后服务管理系统数据建模
实验2.售后服务管理系统数据建模
2022-07-15 11:06:00 【一只野指针.】
售后服务管理系统数据建模
逻辑模型、物理模型、SQL代码与实验报告的位置:
https://download.csdn.net/download/weixin_50836014/85970144
实验报告如下:
一.设计思路:
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/c5/cc7b619afd734bd0fe4094d0f32439.png)
三.物理模型
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-g9VpU67n-1657290970334)(file:///C:\Users\Hasee\AppData\Local\Temp\ksohtml1764\wps2.jpg)]](/img/5f/52d4c457153dd4ace1ebacf317624c.png)
四.实验问题
(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)]](/img/76/40911d3e64a18597ae9f31810cc232.png)
生成的SQL代码如下:
/*==============================================================*/
/* 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
边栏推荐
- 解析协同办公“协同”为何意,数字化办公又如何轻松“破题”?
- 送你的代码上太空,与华为云一起开发“最伟大的作品”
- Issue 40: Reflection on JS function default parameters
- 2020-10-11
- 2022-07-14 第五小组 修身课 学习笔记(every day)
- Idea setting / modifying shortcut keys
- The domain name has been filed, and the trading is strictly controlled. Do you know?
- What is CDN acceleration
- 上海港口航运人工智能集装箱人工智能独角兽中集飞瞳,港航人工智能产品市场占有率领先,带动港航人工智能集装箱人工智能全产业链发展
- agile manifesto
猜你喜欢

Raspberry pie remote desktop display is incomplete

职场大咖带你助攻面试求职+职业发展
![[C data storage]](/img/a7/c237fddead7908003947cd387be90c.png)
[C data storage]

Structure related type resolution

Xu Shiwei: la voie de l'évolution de go +.

Aof of redis persistence

.net core 配置跨域

Chapter 14 multi process

10 minutes to customize the pedestrian analysis system, detection and tracking, behavior recognition, human attributes all in one!

【C】 Creation and destruction of function stack frames
随机推荐
pat刷题
2020-10-11
2022-07-14 study notes of group 5 self-cultivation class (every day)
Software testing W model
What is CDN acceleration
C # flying chess games
owt-server源码剖析(二)--功能模块的内部结构与启动流程
Vessel introduction and summary
【C】 Pointer advanced
CF1422C Bargain (DP+思维+数学)
Engineering monitoring vibrating wire sensor wireless acquisition instrument external digital sensor
300000 prize pool is waiting for you to fight! Natural language processing (NLP) competition collection is coming
Issue 40: Reflection on JS function default parameters
Codeforces Round #736 (Div. 2) (A-D)
Serial communication of raspberry pie
Revelation of AI application: honey and arsenic in security market
Can spiders quickly increase the collection of websites by increasing the frequency of crawling?
Idea setting / modifying shortcut keys
Deep understanding and recognition of C language symbols
[Verilog] 32-bit single precision floating-point number comparison size