系统分析与设计HW5
1、领域建模
- a. 阅读 Asg_RH 文档,按用例构建领域模型。
- 按 Task2 要求,请使用工具 UMLet,截图格式务必是 png 并控制尺寸
- 说明:请不要受 PCMEF 层次结构影响。你需要识别实体(E)和 中介实体(M,也称状态实体)
在单页面应用(如 vue)中,E 一般与数据库构建有关, M 一般与 store 模式 有关
在 java web 应用中,E 一般与数据库构建有关, M 一般与 session 有关
- b. 数据库建模(E-R 模型)
/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2018/4/29 16:33:14 */
/*==============================================================*/
drop table if exists Reservation;
drop table if exists Room;
drop table if exists credit_card;
drop table if exists customer;
drop table if exists hotel;
/*==============================================================*/
/* Table: Reservation */
/*==============================================================*/
create table Reservation
(
order_id int not null,
customer_id int,
check_in_date date,
check_out_date date,
is_paid tinyint(1),
primary key (order_id)
);
/*==============================================================*/
/* Table: Room */
/*==============================================================*/
create table Room
(
room_id int not null,
order_id int,
hotel_id int,
isAva tinyint(1),
date date,
type char(30),
price int,
primary key (room_id)
);
/*==============================================================*/
/* Table: credit_card */
/*==============================================================*/
create table credit_card
(
credit_card char(30) not null,
customer_id int,
security_code char(30),
primary key (credit_card)
);
/*==============================================================*/
/* Table: customer */
/*==============================================================*/
create table customer
(
customer_id int not null,
name char(20),
Email_address char(30),
phone_number char(20),
is_smoking tinyint(1),
primary key (customer_id)
);
/*==============================================================*/
/* Table: hotel */
/*==============================================================*/
create table hotel
(
hotel_id int not null,
name char(20),
star_rating int,
city_name char(30),
primary key (hotel_id)
);
alter table Reservation add constraint FK_Reference_2 foreign key (customer_id)
references customer (customer_id) on delete restrict on update restrict;
alter table Room add constraint FK_Reference_3 foreign key (order_id)
references Reservation (order_id) on delete restrict on update restrict;
alter table Room add constraint FK_Reference_4 foreign key (hotel_id)
references hotel (hotel_id) on delete restrict on update restrict;
alter table credit_card add constraint FK_Reference_1 foreign key (customer_id)
references customer (customer_id) on delete restrict on update restrict;
- 简单叙说数据库逻辑模型与领域模型的异同
数据库逻辑模型与领域模型的相同之处在于两个模型都是确定实体、实体属性以及实体之间的关系。
数据库逻辑模型与领域模型的不同之一在于,领域模型考虑的是除系统和UI实体之外的实体,数据库逻辑模型考虑的是能够在数据库中存储的非暂时性的实体。数据库逻辑模型与领域模型之间的不同还有数据库逻辑模型建模时还要考虑每个实体各个属性以及这些属性的数据结构。