系统分析与设计 Homework(lesson 7)
领域建模
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
导出 Mysql 物理数据库的脚本
/*==============================================================*/ /* DBMS name: MySQL 5.0 */ /* Created on: 2018-04-29 12:14:58 */ /*==============================================================*/ drop table if exists Hotel; drop table if exists Location; drop table if exists Reservation; drop table if exists Room; drop table if exists Traveler; /*==============================================================*/ /* Table: Hotel */ /*==============================================================*/ create table Hotel ( hotel_id int not null, lid int not null, Region char(256), star int, address char(256), primary key (hotel_id) ); /*==============================================================*/ /* Table: Location */ /*==============================================================*/ create table Location ( lid int not null, Region char(256), Region_code int, City char(256), City_code int, City_Capital bool, Town char(256), primary key (lid) ); /*==============================================================*/ /* Table: Reservation */ /*==============================================================*/ create table Reservation ( reserve_id int not null, user_id int not null, hotel_id int not null, check_in_date date, check_out_date date, nights_num int, room_num int, total_due numeric(8,0), isPay bool, make_time datetime, primary key (reserve_id) ); /*==============================================================*/ /* Table: Room */ /*==============================================================*/ create table Room ( room_id int not null, hotel_id int not null, reserve_id int, type char(256), list_price int, isAvailable bool, primary key (room_id) ); /*==============================================================*/ /* Table: Traveler */ /*==============================================================*/ create table Traveler ( user_id int not null, "full name" char(256), "email address" char(256), primary key (user_id) ); alter table Hotel add constraint FK_exist foreign key (lid) references Location (lid) on delete restrict on update restrict; alter table Reservation add constraint FK_at foreign key (hotel_id) references Hotel (hotel_id) on delete restrict on update restrict; alter table Reservation add constraint FK_make foreign key (user_id) references Traveler (user_id) on delete restrict on update restrict; alter table Room add constraint FK_Has foreign key (hotel_id) references Hotel (hotel_id) on delete restrict on update restrict; alter table Room add constraint FK_reserve foreign key (reserve_id) references Reservation (reserve_id) on delete restrict on update restrict;
简单叙说数据库逻辑模型与领域模型的异同
- 相同点
- 都是反映不同实体之间的关系
- 常用于系统分析与设计,特别是涉及数据表的设计
- 不同点
- 领域模型反映的是问题域的相关业务概念以及其关系,来源于业务需求的描述,同时可帮助用户和需求分析人员更好的理解业务需求
- 数据库逻辑模型适用于软件开发者,需考虑系统内数据的具体存放方式,比领域模型考虑方面需要更加细致
- 相同点