1. 领域建模
a.阅读 Asg_RH 文档,按用例构建领域模型。
- 按 Task2 要求,请使用工具 UMLet,截图格式务必是 png 并控制尺寸
- 说明:请不要受 PCMEF 层次结构影响。你需要识别实体(E)和 中介实体(M,也称状态实体)
在单页面应用(如 vue)中,E 一般与数据库构建有关, M 一般与 store 模式 有关
在 java web 应用中,E 一般与数据库构建有关, M 一般与 session 有关
b. 数据库建模(E-R 模型)
- 按 Task 3 要求,给出系统的 E-R 模型(数据逻辑模型)
- 建模工具 PowerDesigner(简称PD) 或开源工具 OpenSystemArchitect
- 不负责的链接 http://www.cnblogs.com/mcgrady/archive/2013/05/25/3098588.html
- 导出 Mysql 物理数据库的脚本
- 简单叙说 数据库逻辑模型 与 领域模型 的异同
/*==============================================================*/
/* DBMS name: Microsoft SQL Server 2012 */
/* Created on: 2018/4/29 21:17:47 */
/*==============================================================*/
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('Hotel') and o.name = 'FK_HOTEL_MANAGER_RESERVAT')
alter table Hotel
drop constraint FK_HOTEL_MANAGER_RESERVAT
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('Reservation') and o.name = 'FK_RESERVAT_MAKE_CUSTOMER')
alter table Reservation
drop constraint FK_RESERVAT_MAKE_CUSTOMER
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('Room') and o.name = 'FK_ROOM_HAVE_HOTEL')
alter table Room
drop constraint FK_ROOM_HAVE_HOTEL
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('payment') and o.name = 'FK_PAYMENT_GENERATE_RESERVAT')
alter table payment
drop constraint FK_PAYMENT_GENERATE_RESERVAT
go
if exists (select 1
from sysobjects
where id = object_id('Customer')
and type = 'U')
drop table Customer
go
if exists (select 1
from sysindexes
where id = object_id('Hotel')
and name = 'manager_FK'
and indid > 0
and indid < 255)
drop index Hotel.manager_FK
go
if exists (select 1
from sysobjects
where id = object_id('Hotel')
and type = 'U')
drop table Hotel
go
if exists (select 1
from sysindexes
where id = object_id('Reservation')
and name = 'make_FK'
and indid > 0
and indid < 255)
drop index Reservation.make_FK
go
if exists (select 1
from sysobjects
where id = object_id('Reservation')
and type = 'U')
drop table Reservation
go
if exists (select 1
from sysindexes
where id = object_id('Room')
and name = 'have_FK'
and indid > 0
and indid < 255)
drop index Room.have_FK
go
if exists (select 1
from sysobjects
where id = object_id('Room')
and type = 'U')
drop table Room
go
if exists (select 1
from sysindexes
where id = object_id('payment')
and name = 'generate_FK'
and indid > 0
and indid < 255)
drop index payment.generate_FK
go
if exists (select 1
from sysobjects
where id = object_id('payment')
and type = 'U')
drop table payment
go
/*==============================================================*/
/* Table: Customer */
/*==============================================================*/
create table Customer (
customer_name char(256) null,
email char(256) null,
telephone char(256) null,
ID char(256) not null,
password char(256) null,
constraint PK_CUSTOMER primary key nonclustered (ID)
)
go
/*==============================================================*/
/* Table: Hotel */
/*==============================================================*/
create table Hotel (
hotelname char(256) not null,
reservation_id char(256) null,
address char(256) null,
contactway char(256) null,
level bigint null,
comment char(256) null,
constraint PK_HOTEL primary key nonclustered (hotelname)
)
go
/*==============================================================*/
/* Index: manager_FK */
/*==============================================================*/
create index manager_FK on Hotel (
reservation_id ASC
)
go
/*==============================================================*/
/* Table: Reservation */
/*==============================================================*/
create table Reservation (
customer_name char(256) null,
roometype char(256) null,
roomquantity bigint null,
date datetime null,
qpplicationservice char(256) null,
hotel char(256) null,
reservation_id char(256) not null,
ID char(256) null,
constraint PK_RESERVATION primary key nonclustered (reservation_id)
)
go
/*==============================================================*/
/* Index: make_FK */
/*==============================================================*/
create index make_FK on Reservation (
ID ASC
)
go
/*==============================================================*/
/* Table: Room */
/*==============================================================*/
create table Room (
hotelname char(256) null,
type char(256) null,
area float null,
configuration char(256) null,
price money null,
quantity bigint null
)
go
/*==============================================================*/
/* Index: have_FK */
/*==============================================================*/
create index have_FK on Room (
hotelname ASC
)
go
/*==============================================================*/
/* Table: payment */
/*==============================================================*/
create table payment (
cardname char(256) null,
paytime datetime null,
buyitem char(256) null,
payment_id char(256) not null,
reservation_id char(256) null,
constraint PK_PAYMENT primary key nonclustered (payment_id)
)
go
/*==============================================================*/
/* Index: generate_FK */
/*==============================================================*/
create index generate_FK on payment (
reservation_id ASC
)
go
alter table Hotel
add constraint FK_HOTEL_MANAGER_RESERVAT foreign key (reservation_id)
references Reservation (reservation_id)
go
alter table Reservation
add constraint FK_RESERVAT_MAKE_CUSTOMER foreign key (ID)
references Customer (ID)
go
alter table Room
add constraint FK_ROOM_HAVE_HOTEL foreign key (hotelname)
references Hotel (hotelname)
go
alter table payment
add constraint FK_PAYMENT_GENERATE_RESERVAT foreign key (reservation_id)
references Reservation (reservation_id)
go
数据库逻辑模型 与 领域模型 异同:
数据库逻辑模型是一个抽象的宏观层次的业务模型,在概念模型中最重要的对象是实体和关系。
领域模型是一个商业建模范畴的概念,他和软件开发并无一丝一毫的关系,即使一个企业他不开发软件,他也具备他的业务模型,所有的同行业的企业他们的业务模型必定有非常大的共性和内在的规律性,由这个行业内的各个企业的业务模型再向上抽象出来整个行业的业务模型,这个东西即“领域模型”。
同:描述的东西类似,结构大体相像。
数据模型是系统设计,以及实现的一部分,描述的是对用户需求在技术上的实现方法。用户不需要关心系统的数据模型,但是必须关注领域模型,因为领域模型反映的是问题域的相关业务概念以及其关系,领域模型是用户业务描述的高度抽象,来源于业务需求的描述,同时又可以帮助用户和需求分析人员更好的理解业务需求。
异:面对的对象不同,目的不同,领域模型更关注功能,数据库模型更关注数据。