设计房屋租赁管理系统--PostgreSQL--数据库原理及应用
第一次 “數(shù)據(jù)庫原理及應(yīng)用”課程實踐大作業(yè)
針對房屋租賃管理系統(tǒng)開發(fā),設(shè)計該系統(tǒng)數(shù)據(jù)庫,并在PostgreSQL數(shù)據(jù)庫服務(wù)器中實現(xiàn)該數(shù)據(jù)庫。
1)分析房屋租賃管理系統(tǒng)業(yè)務(wù)的基本數(shù)據(jù)需求,使用Power Designer建模工具,建立房屋租賃管理系統(tǒng)概念數(shù)據(jù)模型CDM。
2)針對關(guān)系數(shù)據(jù)庫設(shè)計,在Power Designer建模工具中,將房屋租賃管理系統(tǒng)概念數(shù)據(jù)模型轉(zhuǎn)換為系統(tǒng)邏輯數(shù)據(jù)模型LDM設(shè)計,并進行規(guī)范化完善設(shè)計。
3)針對PostgreSQL數(shù)據(jù)庫實現(xiàn),在Power Designer建模工具中,將房屋租賃管理系統(tǒng)邏輯數(shù)據(jù)模型轉(zhuǎn)換為系統(tǒng)物理數(shù)據(jù)模型PDM設(shè)計。
4)在Power Designer建模工具中,將房屋租賃管理系統(tǒng)物理數(shù)據(jù)模型轉(zhuǎn)換為SQL腳本程序。
5)在PostgreSQL數(shù)據(jù)庫服務(wù)器中,執(zhí)行該SQL腳本程序,實現(xiàn)房屋租賃管理系統(tǒng)數(shù)據(jù)庫對象創(chuàng)建實現(xiàn)。
作業(yè)要求:在作業(yè)文檔分別給出房屋租賃管理系統(tǒng)的概念數(shù)據(jù)模型、邏輯數(shù)據(jù)模型、物理數(shù)據(jù)模型模型設(shè)計圖,
并將數(shù)據(jù)庫設(shè)計模型在PostgreSQL數(shù)據(jù)庫服務(wù)器進行實現(xiàn)。給出各個模型設(shè)計步驟、設(shè)計說明、執(zhí)行結(jié)果界面,并對結(jié)果進行說明。
實驗流程
1.新建概念數(shù)據(jù)模型
?2.選取概念數(shù)據(jù)類型,輸入名稱
3.定義租戶實體
?4.命名實體名稱
?5.命名實體屬性
6.同理定義房屋、房主、租貸合同實體
?
7.建立實體聯(lián)系,點取實體聯(lián)系符號,連接“租戶”實體與“房屋”實體
?
8.雙擊聯(lián)系符號,進入聯(lián)系選項設(shè)置,命名實體聯(lián)系名稱
9.設(shè)置實體之間的數(shù)量關(guān)系、參與關(guān)系
10.類似方法建立其他實體之間的聯(lián)系?
?
?
?
?11.保存概念數(shù)據(jù)模型
邏輯數(shù)據(jù)模型設(shè)計圖
1.?? ?在工具欄中選取創(chuàng)建邏輯數(shù)據(jù)模型菜單項
關(guān)于powerdesinger 出現(xiàn)Entity Attribute code uniqueness解決辦法
Tool->check?model...去掉Entity?Attribute下Entity?Attribute?name?uniqueness?和?Entity?Attribute?code?uniqueness
關(guān)于powerdesinger 出現(xiàn)Entity Attribute code uniqueness解決辦法_咸魚恒星的博客-CSDN博客
2.?? ?進入邏輯數(shù)據(jù)模型轉(zhuǎn)換設(shè)置對話框,設(shè)置選項與名稱后,點擊確定
3.?? ?即可將概念數(shù)據(jù)模型轉(zhuǎn)換為邏輯數(shù)據(jù)模型
4.?? ?對轉(zhuǎn)換之后的邏輯數(shù)據(jù)模型進行完善設(shè)計,可以增加實體屬性
5.?? ?為了更完整展示邏輯數(shù)據(jù)模型顯示內(nèi)容,可選取工具菜單欄,顯示選項菜單項;進入模型顯示設(shè)置頁面,對邏輯數(shù)據(jù)模型實體顯示內(nèi)容進行設(shè)置,點取確定,即可看到邏輯數(shù)據(jù)模型完整內(nèi)容
?
物理數(shù)據(jù)模型設(shè)計圖
1.?? ?點取菜單工具Tools->創(chuàng)建物理數(shù)據(jù)模型Generate Physical Data Model
2.?? ?選取DBMS :PostgreSQL 9.x, 命名物理數(shù)據(jù)模型名稱,點擊確定,即可將邏輯數(shù)據(jù)模型轉(zhuǎn)換為物理數(shù)據(jù)模型
3.?? ?對物理數(shù)據(jù)模型的顯示內(nèi)容進行設(shè)置, 可通過點取工具菜單中的顯示選項菜單項, 進入模型顯示設(shè)置頁面, 對物理數(shù)據(jù)模型顯示內(nèi)容進行設(shè)置,即可看到所需要的模型設(shè)計內(nèi)容
?轉(zhuǎn)換為SQL腳本程序,并在PostgreSQL數(shù)據(jù)庫服務(wù)器進行實現(xiàn)。
1.?? ?點取數(shù)據(jù)庫菜單欄"Databases"
2.?? ?點取創(chuàng)建數(shù)據(jù)庫菜單項Generate Database
3.?? ?進入數(shù)據(jù)庫設(shè)置對話框頁面, 在對話框頁面中設(shè)置腳本轉(zhuǎn)換選項,即可轉(zhuǎn)換為SQL腳本程序
?
4.?? ?在文本編輯器中,可以打開創(chuàng)建的SQL文件,即可看到各個數(shù)據(jù)庫對象創(chuàng)建的SQL語句
5.?? ?執(zhí)行SQL腳本創(chuàng)建數(shù)據(jù)庫對象,在PostgreSQL數(shù)據(jù)庫管理工具中,執(zhí)行SQL腳本,實現(xiàn)數(shù)據(jù)庫對象創(chuàng)建
6.?? ?使用pgAdmin4數(shù)據(jù)庫管理工具,連接PostgreSQL數(shù)據(jù)庫服務(wù)器,在服務(wù)器中創(chuàng)建房屋租賃數(shù)據(jù)庫HouseDB
7.?? ?調(diào)入創(chuàng)建數(shù)據(jù)庫對象的SQL腳本文件,Tool,Query Tool
?7.刪除索引文件
?
8.運行 ,刷新數(shù)據(jù)庫,完成
SQL文件內(nèi)容
/*==============================================================*/ /* DBMS name: PostgreSQL 9.x */ /* Created on: 2022?ê4??24è? 19:57:04 */ /*==============================================================*//*==============================================================*/ /* Table: contract */ /*==============================================================*/ create table contract (IDnumber VARCHAR(18) not null,IDnumber2 VARCHAR(18) not null,renttime2 DATE null,owner2 VARCHAR(20) null,address2 VARCHAR(50) null,tenement VARCHAR(20) null );/*==============================================================*/ /* Index: partyB_FK */ /*==============================================================*/ create index partyB_FK on contract ( IDnumber );/*==============================================================*/ /* Index: partyA_FK */ /*==============================================================*/ create index partyA_FK on contract ( IDnumber2 );/*==============================================================*/ /* Table: house */ /*==============================================================*/ create table house (address VARCHAR(50) not null,area NUMERIC(5,2) not null,owner VARCHAR(20) not null,housetype CHAR(4) not null,renttime DATE null,rent VARCHAR(20) null,number SERIAL not null,IDnumber VARCHAR(18) null,IDnumber2 VARCHAR(18) not null,rentstate2 CHAR(4) null,constraint PK_HOUSE primary key (number) );/*==============================================================*/ /* Index: house_PK */ /*==============================================================*/ create unique index house_PK on house ( number );/*==============================================================*/ /* Index: rent_FK */ /*==============================================================*/ create index rent_FK on house ( IDnumber );/*==============================================================*/ /* Index: own_FK */ /*==============================================================*/ create index own_FK on house ( IDnumber2 );/*==============================================================*/ /* Table: owner */ /*==============================================================*/ create table owner (name2 VARCHAR(20) null,gender2 CHAR(2) null,address3 VARCHAR(50) not null,phonenumber2 VARCHAR(11) null,identity CHAR(4) not null,IDnumber2 VARCHAR(18) not null,constraint PK_OWNER primary key (IDnumber2) );/*==============================================================*/ /* Index: owner_PK */ /*==============================================================*/ create unique index owner_PK on owner ( IDnumber2 );/*==============================================================*/ /* Table: tenement */ /*==============================================================*/ create table tenement (IDnumber VARCHAR(18) not null,name VARCHAR(20) not null,gender CHAR(2) not null,phonenumber VARCHAR(11) not null,address VARCHAR(50) not null,renttime DATE null,rentstate2 CHAR(4) null,constraint PK_TENEMENT primary key (IDnumber) );/*==============================================================*/ /* Index: tenement_PK */ /*==============================================================*/ create unique index tenement_PK on tenement ( IDnumber );alter table contractadd constraint FK_CONTRACT_PARTYA_OWNER foreign key (IDnumber2)references owner (IDnumber2)on delete restrict on update restrict;alter table contractadd constraint FK_CONTRACT_PARTYB_TENEMENT foreign key (IDnumber)references tenement (IDnumber)on delete restrict on update restrict;alter table houseadd constraint FK_HOUSE_OWN_OWNER foreign key (IDnumber2)references owner (IDnumber2)on delete restrict on update restrict;alter table houseadd constraint FK_HOUSE_RENT_TENEMENT foreign key (IDnumber)references tenement (IDnumber)on delete restrict on update restrict;總結(jié)
以上是生活随笔為你收集整理的设计房屋租赁管理系统--PostgreSQL--数据库原理及应用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python对excel表统计视频教程_
- 下一篇: ubuntu系统下Java环境JDK的安