homework5
标签(空格分隔): 系统分析与设计
a. 阅读 Asg_RH 文档,按用例构建领域模型。
寻找旅馆的用例对应的领域模型
b. 数据库建模(E-R 模型)
导出的mysql的脚本
/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2018/4/29 22:06:33 */
/*==============================================================*/
drop table if exists creditCard;
drop table if exists hotel;
drop table if exists payment;
drop table if exists reservation;
drop table if exists room;
drop table if exists shoppingBasket;
drop table if exists travler;
/*==============================================================*/
/* Table: creditCard */
/*==============================================================*/
create table creditCard
(
type text,
"NO." int not null,
sid int,
tid int,
securityCode char(30),
primary key ("NO.")
);
/*==============================================================*/
/* Table: hotel */
/*==============================================================*/
create table hotel
(
hid int not null,
rid int,
tid int,
name text,
star text,
hotIndex varchar(40),
city text,
primary key (hid)
);
/*==============================================================*/
/* Table: payment */
/*==============================================================*/
create table payment
(
"NO." int not null,
sid int not null,
numOfReservation char(10),
totalPrice char(10),
primary key ("NO.", sid)
);
/*==============================================================*/
/* Table: reservation */
/*==============================================================*/
create table reservation
(
rid int not null,
sid int,
tid int,
arriavalDate date,
depatureDate date,
numOfRoom int,
numOfAdult int,
numOfChildren int,
primary key (rid)
);
/*==============================================================*/
/* Table: room */
/*==============================================================*/
create table room
(
hid int,
rid int,
type text,
price float
);
/*==============================================================*/
/* Table: shoppingBasket */
/*==============================================================*/
create table shoppingBasket
(
sid int not null,
"NO." int,
primary key (sid)
);
/*==============================================================*/
/* Table: travler */
/*==============================================================*/
create table travler
(
tid int not null,
rid int,
name text,
"e-mail" text,
primary key (tid)
);
alter table creditCard add constraint FK_has2 foreign key (tid)
references travler (tid) on delete restrict on update restrict;
alter table creditCard add constraint FK_use2 foreign key (sid)
references shoppingBasket (sid) on delete restrict on update restrict;
alter table hotel add constraint FK_realtedTo foreign key (rid)
references reservation (rid) on delete restrict on update restrict;
alter table hotel add constraint FK_search foreign key (tid)
references travler (tid) on delete restrict on update restrict;
alter table payment add constraint FK_payment foreign key ("NO.")
references creditCard ("NO.") on delete restrict on update restrict;
alter table payment add constraint FK_payment2 foreign key (sid)
references shoppingBasket (sid) on delete restrict on update restrict;
alter table reservation add constraint FK_contain1 foreign key (sid)
references shoppingBasket (sid) on delete restrict on update restrict;
alter table reservation add constraint FK_make foreign key (tid)
references travler (tid) on delete restrict on update restrict;
alter table room add constraint FK_contain foreign key (rid)
references reservation (rid) on delete restrict on update restrict;
alter table room add constraint FK_has foreign key (hid)
references hotel (hid) on delete restrict on update restrict;
alter table shoppingBasket add constraint FK_use foreign key ("NO.")
references creditCard ("NO.") on delete restrict on update restrict;
alter table travler add constraint FK_make2 foreign key (rid)
references reservation (rid) on delete restrict on update restrict;
简单叙说数据库逻辑模型与领域模型的异同
大体上来讲数据库模型与领域模型是十分相似的,两者描述的东西都是大致相同的,但是使用了不同的方式以不同的角度来对系统进行描述,最终面对的受众不同。
数据库模型采用面向对象的设计方法,有效组织了业务数据,采取了统一的逻辑语言来描述业务,最终可以转换成正确的结果,其最终结果是为了生成相应的数据库中的各种模式和表因而更加偏向于形式化的数据表示。
而领域模型同样采用面向对象的设计方法,注重于业务流程的显示和用例的表示,注重于问题领域本身,更加注重业务本身及其职责。