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 物理数据库的脚本
- 简单叙说 数据库逻辑模型 与 领域模型 的异同
a.
b.
/*==============================================================*/
/* DBMS name: Sybase SQL Anywhere 12 */
/* Created on: 2018/4/29 0:57:49 */
/*==============================================================*/
if exists(select 1 from sys.sysforeignkey where role='FK_HOTEL_REFERENCE_ROOM') then
alter table hotel
delete foreign key FK_HOTEL_REFERENCE_ROOM
end if;
if exists(select 1 from sys.sysforeignkey where role='FK_RESERVAT_REFERENCE_HOTEL') then
alter table reservation
delete foreign key FK_RESERVAT_REFERENCE_HOTEL
end if;
if exists(select 1 from sys.sysforeignkey where role='FK_RESERVAT_REFERENCE_PAYMENT') then
alter table reservation
delete foreign key FK_RESERVAT_REFERENCE_PAYMENT
end if;
if exists(select 1 from sys.sysforeignkey where role='FK_RESERVAT_REFERENCE_TRAVELLE') then
alter table reservation
delete foreign key FK_RESERVAT_REFERENCE_TRAVELLE
end if;
if exists(select 1 from sys.sysforeignkey where role='FK_TRAVELLE_REFERENCE_PAYMENT') then
alter table traveller
delete foreign key FK_TRAVELLE_REFERENCE_PAYMENT
end if;
drop table if exists hotel;
drop table if exists payment;
drop table if exists reservation;
drop table if exists room;
drop table if exists traveller;
/*==============================================================*/
/* Table: hotel */
/*==============================================================*/
create table hotel
(
name text not null,
location text not null,
roomNum int not null,
phoneNum int not null,
constraint PK_HOTEL primary key clustered (name)
);
/*==============================================================*/
/* Table: payment */
/*==============================================================*/
create table payment
(
payId int not null,
price float not null,
payTime datetime not null,
constraint PK_PAYMENT primary key clustered (payId)
);
/*==============================================================*/
/* Table: reservation */
/*==============================================================*/
create table reservation
(
reservationId int not null,
name text null,
payId int null,
accountId text null,
startDate date not null,
endDate date not null,
travellerId text not null,
travellerPhone int not null,
price float not null,
state text not null,
constraint PK_RESERVATION primary key clustered (reservationId)
);
/*==============================================================*/
/* Table: room */
/*==============================================================*/
create table room
(
roomNum int not null,
state char not null,
constraint PK_ROOM primary key clustered (roomNum)
);
/*==============================================================*/
/* Table: traveller */
/*==============================================================*/
create table traveller
(
accountId text not null,
payId int null,
password text not null,
phoneNum int not null,
constraint PK_TRAVELLER primary key clustered (accountId)
);
alter table hotel
add constraint FK_HOTEL_REFERENCE_ROOM foreign key (roomNum)
references room (roomNum)
on update restrict
on delete restrict;
alter table reservation
add constraint FK_RESERVAT_REFERENCE_HOTEL foreign key (name)
references hotel (name)
on update restrict
on delete restrict;
alter table reservation
add constraint FK_RESERVAT_REFERENCE_PAYMENT foreign key (payId)
references payment (payId)
on update restrict
on delete restrict;
alter table reservation
add constraint FK_RESERVAT_REFERENCE_TRAVELLE foreign key (accountId)
references traveller (accountId)
on update restrict
on delete restrict;
alter table traveller
add constraint FK_TRAVELLE_REFERENCE_PAYMENT foreign key (payId)
references payment (payId)
on update restrict
on delete restrict;
在实体的概念上相似,都运用了实体间的关系,实体都有属性,都能简明清晰地表明数据表之间的关系。
领域模型更注重全面的表达功能,数据库更关注数据,并且存在主键外键等约束信息。