系统分析与设计lesson7

1、 领域建模

  • a. 阅读 Asg_RH 文档,按用例构建领域模型。
    • 按 Task2 要求,请使用工具 UMLet,截图格式务必是 png 并控制尺寸
    • 说明:请不要受 PCMEF 层次结构影响。你需要识别实体(E)和 中介实体(M,也称状态实体)
      • 在单页面应用(如 vue)中,E 一般与数据库构建有关, M 一般与 store 模式 有关
      • 在 java web 应用中,E 一般与数据库构建有关, M 一般与 session 有关


/*==============================================================*/
/* DBMS name:      Sybase SQL Anywhere 12                       */
/* Created on:     2018/4/28 21:23:29                            */
/*==============================================================*/




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


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


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


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


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


drop table if exists hotel;


drop table if exists payment;


drop table if exists reservation;


drop table if exists room;


drop table if exists traveller;


/*==============================================================*/
/* Table: hotel                                                 */
/*==============================================================*/
create table hotel 
(
   name                 text                           not null,
   location             text                           not null,
   roomNum              int                            not null,
   phoneNum             int                            not null,
   constraint PK_HOTEL primary key clustered (name)
);


/*==============================================================*/
/* Table: payment                                               */
/*==============================================================*/
create table payment 
(
   payId                int                            not null,
   price                float                          not null,
   payTime              datetime                       not null,
   constraint PK_PAYMENT primary key clustered (payId)
);


/*==============================================================*/
/* Table: reservation                                           */
/*==============================================================*/
create table reservation 
(
   reservationId        int                            not null,
   name                 text                           null,
   payId                int                            null,
   accountId            text                           null,
   startDate            date                           not null,
   endDate              date                           not null,
   travellerId          text                           not null,
   travellerPhone       int                            not null,
   price                float                          not null,
   state                text                           not null,
   constraint PK_RESERVATION primary key clustered (reservationId)
);


/*==============================================================*/
/* Table: room                                                  */
/*==============================================================*/
create table room 
(
   roomNum              int                            not null,
   state                char                           not null,
   constraint PK_ROOM primary key clustered (roomNum)
);


/*==============================================================*/
/* Table: traveller                                             */
/*==============================================================*/
create table traveller 
(
   accountId            text                           not null,
   payId                int                            null,
   password             text                           not null,
   phoneNum             int                            not null,
   constraint PK_TRAVELLER primary key clustered (accountId)
);


alter table hotel
   add constraint FK_HOTEL_REFERENCE_ROOM foreign key (roomNum)
      references room (roomNum)
      on update restrict
      on delete restrict;


alter table reservation
   add constraint FK_RESERVAT_REFERENCE_HOTEL foreign key (name)
      references hotel (name)
      on update restrict
      on delete restrict;


alter table reservation
   add constraint FK_RESERVAT_REFERENCE_PAYMENT foreign key (payId)
      references payment (payId)
      on update restrict
      on delete restrict;


alter table reservation
   add constraint FK_RESERVAT_REFERENCE_TRAVELLE foreign key (accountId)
      references traveller (accountId)
      on update restrict
      on delete restrict;


alter table traveller
   add constraint FK_TRAVELLE_REFERENCE_PAYMENT foreign key (payId)
      references payment (payId)
      on update restrict
      on delete restrict;


    相同点:都能简明清晰地表明数据表之间的关系,关注用例。

    不同点:领域模型更关注功能,数据库更关注数据。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值