本文主要是介绍领域建模-lesson7,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
- 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 物理数据库的脚本
/*==============================================================*/
/* DBMS name: Microsoft SQL Server 2012 */
/* Created on: 2018/5/1 15:39:05 */
/*==============================================================*/if exists (select 1from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')where r.fkeyid = object_id('payment') and o.name = 'FK_PAYMENT_PAY_CUSTOMER')
alter table paymentdrop constraint FK_PAYMENT_PAY_CUSTOMER
goif exists (select 1from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')where r.fkeyid = object_id('payment') and o.name = 'FK_PAYMENT_REQUIRE_RESERVAT')
alter table paymentdrop constraint FK_PAYMENT_REQUIRE_RESERVAT
goif exists (select 1from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')where r.fkeyid = object_id('reservation') and o.name = 'FK_RESERVAT_HAS_HOTEL')
alter table reservationdrop constraint FK_RESERVAT_HAS_HOTEL
goif exists (select 1from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')where r.fkeyid = object_id('reservation') and o.name = 'FK_RESERVAT_MAKE_CUSTOMER')
alter table reservationdrop constraint FK_RESERVAT_MAKE_CUSTOMER
goif exists (select 1from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')where r.fkeyid = object_id('reservation') and o.name = 'FK_RESERVAT_REQUIRE2_PAYMENT')
alter table reservationdrop constraint FK_RESERVAT_REQUIRE2_PAYMENT
goif exists (select 1from 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_HAS_ROOM_HOTEL')
alter table roomdrop constraint FK_ROOM_HAS_ROOM_HOTEL
goif exists (select 1from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')where r.fkeyid = object_id('stay') and o.name = 'FK_STAY_STAY_CUSTOMER')
alter table staydrop constraint FK_STAY_STAY_CUSTOMER
goif exists (select 1from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')where r.fkeyid = object_id('stay') and o.name = 'FK_STAY_STAY2_HOTEL')
alter table staydrop constraint FK_STAY_STAY2_HOTEL
goif exists (select 1from sysobjectswhere id = object_id('customer')and type = 'U')drop table customer
goif exists (select 1from sysobjectswhere id = object_id('hotel')and type = 'U')drop table hotel
goif exists (select 1from sysindexeswhere id = object_id('payment')and name = 'require_FK'and indid > 0and indid < 255)drop index payment.require_FK
goif exists (select 1from sysindexeswhere id = object_id('payment')and name = 'pay_FK'and indid > 0and indid < 255)drop index payment.pay_FK
goif exists (select 1from sysobjectswhere id = object_id('payment')and type = 'U')drop table payment
goif exists (select 1from sysindexeswhere id = object_id('reservation')and name = 'has_FK'and indid > 0and indid < 255)drop index reservation.has_FK
goif exists (select 1from sysindexeswhere id = object_id('reservation')and name = 'require2_FK'and indid > 0and indid < 255)drop index reservation.require2_FK
goif exists (select 1from sysindexeswhere id = object_id('reservation')and name = 'make_FK'and indid > 0and indid < 255)drop index reservation.make_FK
goif exists (select 1from sysobjectswhere id = object_id('reservation')and type = 'U')drop table reservation
goif exists (select 1from sysindexeswhere id = object_id('room')and name = 'has_room_FK'and indid > 0and indid < 255)drop index room.has_room_FK
goif exists (select 1from sysobjectswhere id = object_id('room')and type = 'U')drop table room
goif exists (select 1from sysindexeswhere id = object_id('stay')and name = 'stay2_FK'and indid > 0and indid < 255)drop index stay.stay2_FK
goif exists (select 1from sysindexeswhere id = object_id('stay')and name = 'stay_FK'and indid > 0and indid < 255)drop index stay.stay_FK
goif exists (select 1from sysobjectswhere id = object_id('stay')and type = 'U')drop table stay
go/*==============================================================*/
/* Table: customer */
/*==============================================================*/
create table customer (name text null,"telephone number" text null,"customer id" text not null,constraint PK_CUSTOMER primary key nonclustered ("customer id")
)
go/*==============================================================*/
/* Table: hotel */
/*==============================================================*/
create table hotel (name text null,address text null,"hotel id" text null,Attribute_6 char(10) not null,constraint PK_HOTEL primary key nonclustered (Attribute_6)
)
go/*==============================================================*/
/* Table: payment */
/*==============================================================*/
create table payment (date datetime null,amount float null,payment_id char(10) not null,id char(10) null,"customer id" text null,constraint PK_PAYMENT primary key nonclustered (payment_id)
)
go/*==============================================================*/
/* Index: pay_FK */
/*==============================================================*/
create index pay_FK on payment (
"customer id" ASC
)
go/*==============================================================*/
/* Index: require_FK */
/*==============================================================*/
create index require_FK on payment (
id ASC
)
go/*==============================================================*/
/* Table: reservation */
/*==============================================================*/
create table reservation (date datetime null,customerid text null,"room number" int null,id char(10) not null,"customer id" text null,Attribute_6 char(10) null,payment_id char(10) null,constraint PK_RESERVATION primary key nonclustered (id)
)
go/*==============================================================*/
/* Index: make_FK */
/*==============================================================*/
create index make_FK on reservation (
"customer id" ASC
)
go/*==============================================================*/
/* Index: require2_FK */
/*==============================================================*/
create index require2_FK on reservation (
payment_id ASC
)
go/*==============================================================*/
/* Index: has_FK */
/*==============================================================*/
create index has_FK on reservation (
Attribute_6 ASC
)
go/*==============================================================*/
/* Table: room */
/*==============================================================*/
create table room (type text null,number int not null,Attribute_6 char(10) null,price float null,constraint PK_ROOM primary key nonclustered (number)
)
go/*==============================================================*/
/* Index: has_room_FK */
/*==============================================================*/
create index has_room_FK on room (
Attribute_6 ASC
)
go/*==============================================================*/
/* Table: stay */
/*==============================================================*/
create table stay ("customer id" text not null,Attribute_6 char(10) not null,constraint PK_STAY primary key ("customer id", Attribute_6)
)
go/*==============================================================*/
/* Index: stay_FK */
/*==============================================================*/
create index stay_FK on stay (
"customer id" ASC
)
go/*==============================================================*/
/* Index: stay2_FK */
/*==============================================================*/
create index stay2_FK on stay (
Attribute_6 ASC
)
goalter table paymentadd constraint FK_PAYMENT_PAY_CUSTOMER foreign key ("customer id")references customer ("customer id")
goalter table paymentadd constraint FK_PAYMENT_REQUIRE_RESERVAT foreign key (id)references reservation (id)
goalter table reservationadd constraint FK_RESERVAT_HAS_HOTEL foreign key (Attribute_6)references hotel (Attribute_6)
goalter table reservationadd constraint FK_RESERVAT_MAKE_CUSTOMER foreign key ("customer id")references customer ("customer id")
goalter table reservationadd constraint FK_RESERVAT_REQUIRE2_PAYMENT foreign key (payment_id)references payment (payment_id)
goalter table roomadd constraint FK_ROOM_HAS_ROOM_HOTEL foreign key (Attribute_6)references hotel (Attribute_6)
goalter table stayadd constraint FK_STAY_STAY_CUSTOMER foreign key ("customer id")references customer ("customer id")
goalter table stayadd constraint FK_STAY_STAY2_HOTEL foreign key (Attribute_6)references hotel (Attribute_6)
go
相同:两者都是人们抽象出来用以辅助分析与设计的工具,抽象出主要的类,描述不同类之间的关系。
不同:领域模型是用户业务描述的高度抽象,来源于业务需求的描述,同时又可以帮助用户和需求分析人员更好的理解业务需求。数据库逻辑模型涉及到更多的细节部分,涉及到数据库的具体实现,而领域模型与数据库的具体实现没有很大的联系。
这篇关于领域建模-lesson7的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!