- 领域建模
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 或开源工具 OpenSystemArchitect
导出 Mysql 物理数据库的脚本
/*==============================================================*/
/* DBMS name: Sybase SQL Anywhere 12 */
/* Created on: 2018/4/30 0:10:03 */
/*==============================================================*/
if exists(select 1 from sys.sysforeignkey where role='FK_CUSTOMER_REFERENCE_HOTEL') then
alter table Customer
delete foreign key FK_CUSTOMER_REFERENCE_HOTEL
end if;
if exists(select 1 from sys.sysforeignkey where role='FK_RESERVAT_REFERENCE_ROOM') then
alter table Reservation
delete foreign key FK_RESERVAT_REFERENCE_ROOM
end if;
if exists(select 1 from sys.sysforeignkey where role='FK_RESERVAT_REFERENCE_CUSTOMER') then
alter table Reservation
delete foreign key FK_RESERVAT_REFERENCE_CUSTOMER
end if;
if exists(select 1 from sys.sysforeignkey where role='FK_ROOM_REFERENCE_HOTEL') then
alter table Room
delete foreign key FK_ROOM_REFERENCE_HOTEL
end if;
drop table if exists Customer;
drop table if exists Hotel;
drop table if exists Reservation;
drop table if exists Room;
/*==============================================================*/
/* Table: Customer */
/*==============================================================*/
create table Customer
(
"Customer ID" integer not null,
"Hotel ID" integer null,
name char(50) null,
phone char(50) null,
constraint PK_CUSTOMER primary key clustered ("Customer ID")
);
/*==============================================================*/
/* Table: Hotel */
/*==============================================================*/
create table Hotel
(
"Hotel ID" integer not null,
name char(50) null,
price varchar(50) null,
location char(50) null,
constraint PK_HOTEL primary key clustered ("Hotel ID")
);
/*==============================================================*/
/* Table: Reservation */
/*==============================================================*/
create table Reservation
(
"Reservation ID" integer not null,
"Room ID" integer null,
"Customer ID" integer null,
"Customer info" char(50) null,
"Room info" char(50) null,
checkin_data char(50) null,
checkout_data char(50) null,
constraint PK_RESERVATION primary key clustered ("Reservation ID")
);
/*==============================================================*/
/* Table: Room */
/*==============================================================*/
create table Room
(
"Room ID" integer not null,
"Hot_Hotel ID" integer null,
type char(50) null,
price integer null,
"Hotel ID" char(50) null,
constraint PK_ROOM primary key clustered ("Room ID")
);
alter table Customer
add constraint FK_CUSTOMER_REFERENCE_HOTEL foreign key ("Hotel ID")
references Hotel ("Hotel ID")
on update restrict
on delete restrict;
alter table Reservation
add constraint FK_RESERVAT_REFERENCE_ROOM foreign key ("Room ID")
references Room ("Room ID")
on update restrict
on delete restrict;
alter table Reservation
add constraint FK_RESERVAT_REFERENCE_CUSTOMER foreign key ("Customer ID")
references Customer ("Customer ID")
on update restrict
on delete restrict;
alter table Room
add constraint FK_ROOM_REFERENCE_HOTEL foreign key ("Hot_Hotel ID")
references Hotel ("Hotel ID")
on update restrict
on delete restrict;
简单叙说数据库逻辑模型与领域模型的异同
相同:都是用来抽象出主要的类,描述不同类之间的关系,从而辅助分析与设计。
不同处:领域模型是对用户业务的领域描述的高度抽象,可以帮助需求分析人员快速熟悉目标领域的词汇和操作,从而更好的理解业务需求;不涉及到具体的实现。但数据库逻辑模型涉及到数据库的具体实现,对象是实体和关系(ER),描述了具体的实现方法。
此外,用户只需要关心领域模型,开发人员通过领域模型的描述,构建数据库逻辑模型。