# DBMS Test 2 (3/18) <style> .markdown-body li + li { padding-top: 0 !important; } </style> --- [TOC] --- ## 5. 資料庫設計與實體關聯模型 ### 資料庫設計的基礎 - 資料庫系統開發的生命週期 1. 初步規劃(Preliminary Planning) 2. 需求收集與分析(Requirement Collection and Analysis) 3. 設計(Design) 4. 實作(Implementation) 5. 維護(Maintenance) - 完整資料庫設計: - 資料庫設計(Database Design):將概念資料模型轉換成資料庫 - 應用程式設計(Application Design):建立 UI、將商業處理流程轉換成應用程式,即「資料庫程式設計」(Database Programming) - 資料庫設計方法論-三階段:  1. 概念資料庫設計(Conceptionual Database Design) 2. 邏輯資料庫設計(Logical Database Design) - 將實體關聯圖轉換成關聯表綱要 - 關聯表的正規化 3. 實體資料庫設計(Physical Database Design):將邏輯資料模型轉換成 RDBMS 的一系列 SQL 指令敘述 ### 實體關聯模型 - 實體關聯模型(Entity-Relationship Model):1976 年 Peter Chen 延伸 Codd, E.f. 關聯式資料模型(Relational Data Model)理論所開發的資料塑模方法 - 使用實體(Entities)與關聯性(Relationship)描述資料與資料間的關係 - 將真實世界的資料模型化成為邏輯關聯資料(Logically Related Data) - 實體(Entities):真實世界的資料中所識別出的東西,即「實體實例」(Entity Instance) - 一定屬於資料庫系統範圍之內的東西 - 至少擁有一個不是鍵(即關連表主鍵)的屬性 - 實體型態(Entity Type):可將實體分類成不同的實體型態 - 實體型態名稱(Entity Type Name):實體型態的名字 - 實體集合(Entity Set):同一類實例的集合,也就是一個關聯表 - 關聯性(Relationships):二或多個實體間所擁有的關係,即「關聯實例」(Relationship Instances) - 關聯集合(Relationship Set):將關聯實例收集起來的集合,可將其歸類成「關聯型態」(Relationship Type) - 屬性(Attributes):實體所擁有的特性 - 屬性型態(Attribute Type):屬性的所有可能值,即「值集合」(Value Set),相當於關聯表的「定義域」(Domain) ### 建立實體關聯圖 :::info :::spoiler Cheatsheet 1  ::: :::warning :::spoiler Cheatsheet 2 全圖:https://i.imgur.com/YtULEaW.png 註:它的 Chen Notation 的關聯線有些不同 ---   ---   ::: - 實體關聯圖(Entity-Relationship Diagram, ERD):使用圖形符號表示的實體關聯模型 - 實體關聯圖的基本建立步驟 1. 從系統中找出實體型態 2. 找出實體型態與其他實體型態間的關聯 3. 定義實體型態間的關聯型態種類:一對一、一對多或多對多關聯型態 4. 定義實體型態的屬性型態與主鍵 - 關聯型態(Relationship Types):屬於一種「結合實體型態」(Associate Entity Type) - 遞迴(Recursuve):實體型態本身會參與關聯自己的關聯型態 - 關聯限制型態(Relationship Constraints):實體關聯圖中,關聯型態連接的實體型態可以指定的限制條件 - 基數比限制條件(Cardinality Ratio Constraints):限制關聯型態的實例個數: - 一對一關聯性(One-to-one Relationship, 1:1) - 一對多關聯性(One-to-many Relationship, 1:N) - 多對多關聯性(Many-to-many Relationship, M:N) - 基數限制條件(Cardinality Constraints):實體允許參與關聯性的範圍,即 `(min, max)` - 參與限制條件(Participation Constraints):實體集合的實例是全部或部分參與關聯型態 - 全部參與限制條件(Total Participation Constraints):即「存在相依」(Existence Dependency) - 部分參與限制條件(Partial Participation Constraints) - 屬性(Attributes):實體與關聯型態可以有零到多個的特性 - 單元值屬性型態(Atomic Attribute Types):只擁有單元值 - 複合屬性型態(Composite Attribute Types):由多個單元屬性組成 - 多重值屬性型態(Multivalue Attribute Types):屬性不是單元值,而是多重值 - 導出屬性型態(Derived Attribute Types):可以由其它屬性計算出的屬性 - 鍵屬性型態(Key Attribute Types):實體型態中用來辨識實例的屬性,相當於關聯表中的主鍵 - 強實體型態(Strong Entity Type):擁有主鍵的實體型態,即「一般實體型態」(Regular Entity Type) - 弱實體型態(Weak Entity Types):需要依賴其他實體型態才能存在的實體型態,這是沒有主鍵的實體型態 - 一定關聯到一個強實體型態,以辨識其身分,此強實體型態稱為「識別實體型態」(Identifying Entity Type),此關聯型態稱為「識別關聯型態」(Identifying Relationship Type) ### 實體關聯圖的常見錯誤 - 連接陷阱(Connection Traps):錯誤解實體間的關聯性造成實體關聯圖的錯誤 - 扇形陷阱(Fan Traps):實體間的關聯性令人產生混淆 - 通常產生在實體型態擁有多個一對多的關聯型態 - 可以改以其他實體作為建立關係性的橋樑 - 斷層陷阱(Chasm Traps):實體間應該存在的關係根本不存在 - 可以新增關聯型態 - 繪製 ERD 時常見的錯誤 - 實體型態沒有關鍵屬性 - 將一個複合關鍵屬性的各個屬性都畫上底線 - 不當使用多元關係型態 - 存在多餘(不必要、可輕易推導)的關係型態 ## 6. E-R 資料模型 ==(部分略)== - 屬性 - 簡單屬性(Simple Attribute)、複合屬性(Composite Attribute) - 鍵(Key) - 單值屬性(Single-valued Attribute)、多值屬姓(Multi-valued Attribute) - 衍生屬性(Derived Attribute) - 基數限制條件:也可以用 `[min, max]` 表示 - The External Model:ERD 旁寫註釋 - The Internal Model:內部綱要、DDL ## 7. ER Model ==(全略)== ## 練習題 https://ncueeclass.ncu.edu.tw/share/pdfDownload/ERD%20%E8%A7%A3%E7%AD%94?mediaId=66142  --- 
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.