系统分析与设计第五次作业
程序员文章站
2022-05-07 23:02:08
...
1、领域建模
a.阅读Asg_RH文档,按用例构建领域模型。
所构建领域模型如下:
b.数据库建模(E-R模型)
(1)系统的E-R模型(数据逻辑模型)
(2)导出的Mysql物理数据库的脚本如下:
drop table if exists City;
drop table if exists Customer;
drop table if exists Hotel;
drop table if exists Reservation;
drop table if exists Room;
drop table if exists Shopping_Busket;
/*==============================================================*/
/* Table: City */
/*==============================================================*/
create table City
(
name longtext not null,
primary key (name)
);
/*==============================================================*/
/* Table: Customer */
/*==============================================================*/
create table Customer
(
name longtext not null,
phone longtext,
email longtext,
primary key (name)
);
/*==============================================================*/
/* Table: Hotel */
/*==============================================================*/
create table Hotel
(
name longtext not null,
RoomType longtext,
CityName longtext,
primary key (name)
);
/*==============================================================*/
/* Table: Reservation */
/*==============================================================*/
create table Reservation
(
Id int not null,
CustomerName longtext,
HotelName longtext,
RoomType longtext,
CheckInDate date,
CheckOutDate date,
primary key (Id)
);
/*==============================================================*/
/* Table: Room */
/*==============================================================*/
create table Room
(
type longtext not null,
amount int,
primary key (type)
);
/*==============================================================*/
/* Table: Shopping_Busket */
/*==============================================================*/
create table Shopping_Busket
(
ownerName longtext,
reservationId int,
Id int not null,
primary key (Id)
);
alter table Hotel add constraint "FK_Have Rooms" foreign key (RoomType)
references Room (type) on delete restrict on update restrict;
alter table Hotel add constraint "FK_Locates In" foreign key (CityName)
references City (name) on delete restrict on update restrict;
alter table Hotel add constraint FK_Relationship_5 foreign key (name)
references City (name) on delete restrict on update restrict;
alter table Reservation add constraint "FK_Make Reservation" foreign key (CustomerName)
references Customer (name) on delete restrict on update restrict;
alter table Reservation add constraint "FK_Reserve Hotels" foreign key (HotelName)
references Hotel (name) on delete restrict on update restrict;
alter table Shopping_Busket add constraint "FK_Belongs to" foreign key (ownerName)
references Customer (name) on delete restrict on update restrict;
alter table Shopping_Busket add constraint "FK_Include Reservation" foreign key (reservationId)
references Reservation (Id) on delete restrict on update restrict;
(3)数据库逻辑模型与领域模型的异同: 数据库逻辑模型是一个抽象的宏观层次的业务模型,其中最重要的对象是实体与关系。逻辑模型其实就是将概念模型具体化的一个过程,即按照概念结构设计阶段建立的基本E-R图,按选定的管理系统软件支持的数据模型(层次、网状、关系、面向对象),转换成相应的逻辑模型。这种转换要符合关系数据模型的原则。目前最流行就是关系模型(也就是对应的关系数据库)。
领域模型是一个商业建模范畴的概念,是对领域内的概念类或现实世界的对象的一种抽象的可视化表示。它主要关注问题域本身,挖掘问题域中核心的领域概念,并建立领域概念之间的关系。它与软件开发没有关系,即使一个企业他不开发软件,它也具备它的业务模型,所有的同行业的企业它们的业务模型必定有非常大的共性和内在的规律性,由这个行业内的各个企业的业务模型再向上抽象出来整个行业的业务模型,这个东西即“领域模型”。
相同点:两者都是抽象概念,将需求抽象为可视化的概念关系。
不同点:领域模型主要关注现实世界的行为、对象和各种概念,与软件开发本身并无关系;而数据库逻辑模型则是对领域模型的进一步细化,需要摒弃无关的概念,具体实现需要的概念,并将其进一步细化为数据库、类对象等细节。
上一篇: 一天一大 leet