系统分析与设计-第五次作业

系统分析与设计-第五次作业

a. 阅读 Asg_RH 文档,按用例构建领域模型。

按 Task2 要求,请使用工具 UMLet,截图格式务必是 png 并控制尺寸

  • 说明:请不要受 PCMEF 层次结构影响。你需要识别实体(E)和 中介实体(M,也称状态实体)
  • 在单页面应用(如 vue)中,E 一般与数据库构建有关, M 一般与 store 模式 有关
  • 在 java web 应用中,E 一般与数据库构建有关, M 一般与 session 有关

Stary 2018-04-27 at 11.07.07 P

b. 数据库建模(E-R 模型)

  • 按 Task 3 要求,给出系统的 E-R 模型(数据逻辑模型)
  • 建模工具 PowerDesigner(简称PD) 或开源工具 OpenSystemArchitect
  • 不负责的链接 http://www.cnblogs.com/mcgrady/archive/2013/05/25/3098588.html
  • 导出 Mysql 物理数据库的脚本
  • 简单叙说 数据库逻辑模型 与 领域模型 的异同

数据逻辑模型

Stary 2018-04-28 at 12.33.29 A

数据物理模型

Stary 2018-04-28 at 12.52.23 A

Mysql 导出脚本

if exists(select 1 from sys.sysforeignkey where role='FK_HOTELS_REFERENCE_LOCATION') then
    alter table hotels
       delete foreign key FK_HOTELS_REFERENCE_LOCATION
end if;

if exists(select 1 from sys.sysforeignkey where role='FK_HOTELS_REFERENCE_ROOMS') then
    alter table hotels
       delete foreign key FK_HOTELS_REFERENCE_ROOMS
end if;

if exists(select 1 from sys.sysforeignkey where role='FK_ORDERS_REFERENCE_HOTELS') then
    alter table orders
       delete foreign key FK_ORDERS_REFERENCE_HOTELS
end if;

if exists(select 1 from sys.sysforeignkey where role='FK_ORDERS_REFERENCE_ROOMS') then
    alter table orders
       delete foreign key FK_ORDERS_REFERENCE_ROOMS
end if;

if exists(select 1 from sys.sysforeignkey where role='FK_ORDERS_REFERENCE_PAYMENT') then
    alter table orders
       delete foreign key FK_ORDERS_REFERENCE_PAYMENT
end if;

if exists(select 1 from sys.sysforeignkey where role='FK_ROOMS_REFERENCE_DESCRIPT') then
    alter table rooms
       delete foreign key FK_ROOMS_REFERENCE_DESCRIPT
end if;

drop table if exists description;

drop table if exists hotels;

drop table if exists location;

drop table if exists orders;

drop table if exists payment;

drop table if exists rooms;

/*==============================================================*/
/* Table: description                                           */
/*==============================================================*/
create table description 
(
   description_id       integer                        not null,
   type                 long varchar                   null,
   price                float                          null,
   "num of people"      integer                        null,
   constraint PK_DESCRIPTION primary key clustered (description_id)
);

/*==============================================================*/
/* Table: hotels                                                */
/*==============================================================*/
create table hotels 
(
   hotel_id             integer                        not null,
   loacation_id         integer                        null,
   room_id              integer                        null,
   names                long varchar                   not null,
   rating               float                          not null,
   constraint PK_HOTELS primary key clustered (hotel_id)
);

/*==============================================================*/
/* Table: location                                              */
/*==============================================================*/
create table location 
(
   loacation_id         integer                        not null,
   code                 text                           not null,
   name                 text                           not null,
   hot                  bit                            not null,
   constraint PK_LOCATION primary key clustered (loacation_id)
);

/*==============================================================*/
/* Table: orders                                                */
/*==============================================================*/
create table orders 
(
   order_id             integer                        not null,
   hotel_id             integer                        null,
   room_id              integer                        null,
   payment_id           integer                        null,
   "check in date"      date                           null,
   "check out date"     date                           null,
   constraint PK_ORDERS primary key clustered (order_id)
);

/*==============================================================*/
/* Table: payment                                               */
/*==============================================================*/
create table payment 
(
   payment_id           integer                        not null,
   "credit card type"   long varchar                   null,
   "card number"        long varchar                   null,
   "card secruity code" long varchar                   null,
   "cardholder's address details" long varchar                   null,
   constraint PK_PAYMENT primary key clustered (payment_id)
);

/*==============================================================*/
/* Table: rooms                                                 */
/*==============================================================*/
create table rooms 
(
   room_id              integer                        not null,
   description_id       integer                        null,
   num                  integer                        not null,
   constraint PK_ROOMS primary key clustered (room_id)
);

alter table hotels
   add constraint FK_HOTELS_REFERENCE_LOCATION foreign key (loacation_id)
      references location (loacation_id)
      on update restrict
      on delete restrict;

alter table hotels
   add constraint FK_HOTELS_REFERENCE_ROOMS foreign key (room_id)
      references rooms (room_id)
      on update restrict
      on delete restrict;

alter table orders
   add constraint FK_ORDERS_REFERENCE_HOTELS foreign key (hotel_id)
      references hotels (hotel_id)
      on update restrict
      on delete restrict;

alter table orders
   add constraint FK_ORDERS_REFERENCE_ROOMS foreign key (room_id)
      references rooms (room_id)
      on update restrict
      on delete restrict;

alter table orders
   add constraint FK_ORDERS_REFERENCE_PAYMENT foreign key (payment_id)
      references payment (payment_id)
      on update restrict
      on delete restrict;

alter table rooms
   add constraint FK_ROOMS_REFERENCE_DESCRIPT foreign key (description_id)
      references description (description_id)
      on update restrict
      on delete restrict;

数据库逻辑模型 与 领域模型 异同

  • 数据库逻辑模型借助相对抽象、逻辑统一且结构稳健的结构,实现数据仓库系统所要求的数据存储目标,支持大量的分析应用,是实现业务智能的重要基础,同时也是数据管理分析的工具和交流的有效手段。
  • 领域模型是对业务角色和业务实体之间应该如何联系和协作以执行业务的一种抽象。对象模型从业务角色内部的观点定义了业务用例,该模型为产生预期效果确定了业务人员以及他们处理和使用的对象之间应该具有的静态和动态关系,它注重业务中承担的角色及其当前职责。
  • 相同点:定义实体对象之间的关系。
  • 差异点:数据库逻辑模型强调对象属性之间的关系,领域模型强调对象间行为动作之间的关系。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章