领域建模

| 分类 software  engineering  | 标签 系统分析与设计 

领域建模

这里的文章除了特别说明为 [转载] 之外,均为本人原创,转载请说明出处


1、 领域建模

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

按 Task2 要求,请使用工具 UMLet,截图格式务必是 png 并控制尺寸 说明:请不要受 PCMEF 层次结构影响。你需要识别实体(E)和 中介实体(M,也称状态实体)

  • 在单页面应用(如 vue)中,E一般与数据库构建有关,M 一般与store模式有关
  • 在 java web 应用中,E 一般与数据库构建有关, M 一般与 session 有关

Task2: Develop a class model for business objects and business logic in “Reserve Hotel”. The class model should show attributes in classes and relationships between classes.

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

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

系统的 E-R 模型

Mysql 物理数据库的脚本

/*==============================================================*/
/* DBMS name:      Microsoft SQL Server 2012                    */
/* Created on:     2018/4/29 20:44:17                           */
/*==============================================================*/


if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('Hotel') and o.name = 'FK_HOTEL_RELATIONS_LOCATION')
alter table Hotel
   drop constraint FK_HOTEL_RELATIONS_LOCATION
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('RequestSpecification') and o.name = 'FK_REQUESTS_RELATIONS_RESERVAT')
alter table RequestSpecification
   drop constraint FK_REQUESTS_RELATIONS_RESERVAT
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('ReservationRequest') and o.name = 'FK_RESERVAT_HAS_HOTEL')
alter table ReservationRequest
   drop constraint FK_RESERVAT_HAS_HOTEL
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('ReservationRequest') and o.name = 'FK_RESERVAT_LOGGED_CUSTOMER')
alter table ReservationRequest
   drop constraint FK_RESERVAT_LOGGED_CUSTOMER
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('Room') and o.name = 'FK_ROOM_RELATIONS_HOTEL')
alter table Room
   drop constraint FK_ROOM_RELATIONS_HOTEL
go

if exists (select 1
            from  sysobjects
           where  id = object_id('Customer')
            and   type = 'U')
   drop table Customer
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('Hotel')
            and   name  = 'Relationship_1_FK'
            and   indid > 0
            and   indid < 255)
   drop index Hotel.Relationship_1_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('Hotel')
            and   type = 'U')
   drop table Hotel
go

if exists (select 1
            from  sysobjects
           where  id = object_id('Location')
            and   type = 'U')
   drop table Location
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('RequestSpecification')
            and   name  = 'Relationship_4_FK'
            and   indid > 0
            and   indid < 255)
   drop index RequestSpecification.Relationship_4_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('RequestSpecification')
            and   type = 'U')
   drop table RequestSpecification
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('ReservationRequest')
            and   name  = 'logged_FK'
            and   indid > 0
            and   indid < 255)
   drop index ReservationRequest.logged_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('ReservationRequest')
            and   name  = 'has_FK'
            and   indid > 0
            and   indid < 255)
   drop index ReservationRequest.has_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('ReservationRequest')
            and   type = 'U')
   drop table ReservationRequest
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('Room')
            and   name  = 'Relationship_5_FK'
            and   indid > 0
            and   indid < 255)
   drop index Room.Relationship_5_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('Room')
            and   type = 'U')
   drop table Room
go

/*==============================================================*/
/* Table: Customer                                              */
/*==============================================================*/
create table Customer (
   Customer_Name        char(256)            null,
   Email                char(256)            not null,
   constraint PK_CUSTOMER primary key nonclustered (Email)
)
go

/*==============================================================*/
/* Table: Hotel                                                 */
/*==============================================================*/
create table Hotel (
   Hotel_ID             int                  not null,
   Location_Code        int                  null,
   Hotel_Name           char(256)            null,
   star                 int                  null,
   Hotel_Address        char(256)            null,
   constraint PK_HOTEL primary key nonclustered (Hotel_ID)
)
go

/*==============================================================*/
/* Index: Relationship_1_FK                                     */
/*==============================================================*/
create index Relationship_1_FK on Hotel (
Location_Code ASC
)
go

/*==============================================================*/
/* Table: Location                                              */
/*==============================================================*/
create table Location (
   Location_Code        int                  not null,
   Location_Name        char(256)            null,
   Hot                  float                null,
   constraint PK_LOCATION primary key nonclustered (Location_Code)
)
go

/*==============================================================*/
/* Table: RequestSpecification                                  */
/*==============================================================*/
create table RequestSpecification (
   Request_ID           int                  null,
   NumOfAdult           int                  null,
   NumOfChildren        int                  null,
   Room_Number          int                  null
)
go

/*==============================================================*/
/* Index: Relationship_4_FK                                     */
/*==============================================================*/
create index Relationship_4_FK on RequestSpecification (
Request_ID ASC
)
go

/*==============================================================*/
/* Table: ReservationRequest                                    */
/*==============================================================*/
create table ReservationRequest (
   Request_ID           int                  not null,
   Hotel_ID             int                  null,
   Email                char(256)            null,
   CheckInDate          datetime             null,
   CheckOutDate         datetime             null,
   constraint PK_RESERVATIONREQUEST primary key nonclustered (Request_ID)
)
go

/*==============================================================*/
/* Index: has_FK                                                */
/*==============================================================*/
create index has_FK on ReservationRequest (
Hotel_ID ASC
)
go

/*==============================================================*/
/* Index: logged_FK                                             */
/*==============================================================*/
create index logged_FK on ReservationRequest (
Email ASC
)
go

/*==============================================================*/
/* Table: Room                                                  */
/*==============================================================*/
create table Room (
   Date                 datetime             null,
   IsAvailable          bit                  null,
   Room_Type            char(256)            null,
   Room_Price           float                null,
   Room_ID              int                  not null,
   Hotel_ID             int                  null,
   constraint PK_ROOM primary key nonclustered (Room_ID)
)
go

/*==============================================================*/
/* Index: Relationship_5_FK                                     */
/*==============================================================*/
create index Relationship_5_FK on Room (
Hotel_ID ASC
)
go

alter table Hotel
   add constraint FK_HOTEL_RELATIONS_LOCATION foreign key (Location_Code)
      references Location (Location_Code)
go

alter table RequestSpecification
   add constraint FK_REQUESTS_RELATIONS_RESERVAT foreign key (Request_ID)
      references ReservationRequest (Request_ID)
go

alter table ReservationRequest
   add constraint FK_RESERVAT_HAS_HOTEL foreign key (Hotel_ID)
      references Hotel (Hotel_ID)
go

alter table ReservationRequest
   add constraint FK_RESERVAT_LOGGED_CUSTOMER foreign key (Email)
      references Customer (Email)
go

alter table Room
   add constraint FK_ROOM_RELATIONS_HOTEL foreign key (Hotel_ID)
      references Hotel (Hotel_ID)
go


  • 简单叙说 数据库逻辑模型与领域模型的异同

    领域模型是对领域内的概念类或现实世界的对象的一种抽象的可视化表示。又称为概念模型,它主要关注问题域本身,挖掘问题域中核心的领域概念,并建立领域概念之间的关系。

    • 领域模型是在了解了用户的需求,用户的业务领域工作情况以后,分析和总结出来的用以描述用户业务需求的一些概念的东西,和软件开发没有任何关系。
    • 逻辑模型是将领域模型具体化。要实现概念模型所描述的东西,需要哪些具体的功能和处理哪些具体的信息,属于需求分析的细化阶段。系统需要建立几个数据表,系统要包括几个功能,均属于建立逻辑模型。
    • 这两个过程,就是实现一个软件系统的两个关键的步骤,是一个从抽象到具体的一个不断细化完善的分析,设计和开发的过程。

上一篇     下一篇