系統分析與設計-第五次作業
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 物理數據庫的腳本
- 簡單敘說 數據庫邏輯模型 與 領域模型 的異同
數據邏輯模型
數據物理模型
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;
數據庫邏輯模型 與 領域模型 異同
- 數據庫邏輯模型藉助相對抽象、邏輯統一且結構穩健的結構,實現數據倉庫系統所要求的數據存儲目標,支持大量的分析應用,是實現業務智能的重要基礎,同時也是數據管理分析的工具和交流的有效手段。
- 領域模型是對業務角色和業務實體之間應該如何聯繫和協作以執行業務的一種抽象。對象模型從業務角色內部的觀點定義了業務用例,該模型爲產生預期效果確定了業務人員以及他們處理和使用的對象之間應該具有的靜態和動態關係,它注重業務中承擔的角色及其當前職責。
- 相同點:定義實體對象之間的關係。
- 差異點:數據庫邏輯模型強調對象屬性之間的關係,領域模型強調對象間行爲動作之間的關係。