Logical Design for the Relational Model

Slides:



Advertisements
Similar presentations
Installment 7 Tables With No Column Presented by rexmen 2001 資管所.林彥廷.
Advertisements

FCU, Department of ECE, IC Design Research Lab. TEL: # 4945 Pre-SIm , Post-Sim.
Software Engineering for Digital Home 單元 2 :軟體處理程序與需求分析 2-3 需求工程處理程序 Presenter: Away.
Divide-and-Conquer. 什麼是 divide-and-conquer ? Divide 就是把問題分割 Conquer 則是把答案結合起來.
Chapter 10 馬可夫鏈 緒言 如果讀者仔細觀察日常生活中所發生的 諸多事件,必然會發現有些事件的未來 發展或演變與該事件現階段的狀況全然 無關,這種事件稱為獨立試行過程 (process of independent trials) ;而另一些 事件則會受到該事件現階段的狀況影響。
布林代數的應用--- 全及項(最小項)和全或項(最大項)展開式
第七章 抽樣與抽樣分配 蒐集統計資料最常見的方式是抽查。這 牽涉到兩個問題: 抽出的樣本是否具有代表性?是否能反應出母體的特徵?
: A-Sequence 星級 : ★★☆☆☆ 題組: Online-judge.uva.es PROBLEM SET Volume CIX 題號: Problem D : A-Sequence 解題者:薛祖淵 解題日期: 2006 年 2 月 21 日 題意:一開始先輸入一個.
:Word Morphing ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10508:word morphing 解題者:楊家豪 解題日期: 2006 年 5 月 21 日 題意: 第一行給你兩個正整數, 第一個代表下面會出現幾個字串,
Event Sampling 事件取樣法. 關心重點為「事件」本身明確的焦點 行為 清楚掌握主題 - 當「事件」出現時才開 始記錄 記錄程序 等待目標事件的發生 開始記錄 事件結束,停止記錄.
第二章 太陽能電池的基本原理 及其結構 2-1 太陽能電池的基本原理 2-2 太陽能電池的基本結構 2-3 太陽能電池的製作.
3Com Switch 4500 切VLAN教學.
指導教授:陳淑媛 學生:李宗叡 李卿輔.  利用下列三種方法 (Edge Detection 、 Local Binary Pattern 、 Structured Local Edge Pattern) 來判斷是否為場景變換,以方便使用者來 找出所要的片段。
1.1 線性方程式系統簡介 1.2 高斯消去法與高斯-喬登消去法 1.3 線性方程式系統的應用(-Skip-)
消費者物價指數反映生活成本。當消費者物價指數上升時,一般家庭需要花費更多的金錢才能維持相同的生活水準。經濟學家用物價膨脹(inflation)來描述一般物價持續上升的現象,而物價膨脹率(inflation rate)為物價水準的變動百分比。
Chapter 2 聯立線性方程式與矩陣 緒言 線性方程式組 (systems of linear equations) 出現 在多數線性模式 (linear model) 中。根據以往解 題的經驗,讀者們也許已發現方程式的解僅與 該方程式的係數有關,求解的過程也僅與係數 的運算有關,只要係數間的相關位置不改變,
STAT0_sampling Random Sampling  母體: Finite population & Infinity population  由一大小為 N 的有限母體中抽出一樣本數為 n 的樣 本,若每一樣本被抽出的機率是一樣的,這樣本稱 為隨機樣本 (random sample)
第一章 信號與系統初論 信號的簡介與DSP的處理方式。 系統特性與穩定性的判定方法。 以MATLAB驗證系統的線性、非時變、因果等特性。
中央大學。范錚強 1 從 ER 到 Logical Schema ── 兼談 Schema Integration 國立中央大學 資訊管理系 范錚強 2005.
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 肆 資料分析與表達.
Introduction to Java Programming Lecture 17 Abstract Classes & Interfaces.
: The largest Clique ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11324: The largest Clique 解題者:李重儀 解題日期: 2008 年 11 月 24 日 題意: 簡單來說,給你一個 directed.
最新計算機概論 第 5 章 系統程式. 5-1 系統程式的類型 作業系統 (OS) : 介於電腦硬體與 應用軟體之間的 程式,除了提供 執行應用軟體的 環境,還負責分 配系統資源。
3-3 使用幾何繪圖工具 Flash 的幾何繪圖工具包括線段工具 (Line Tool) 、橢圓形工具 (Oval Tool) 、多邊星形 工具 (Rectangle Tool) 3 種。這些工具畫出 來的幾何圖形包括了筆畫線條和填色區域, 將它們適當地組合加上有技巧地變形與配 色, 不但比鉛筆工具簡單,
Matlab Assignment Due Assignment 兩個 matlab 程式 : Eigenface : Eigenvector 和 eigenvalue 的應用. Fractal : Affine transform( rotation, translation,
Chapter 20 塑模動態觀點:狀態圖 Statechart Diagram. 學習目標  說明狀態圖的目的  定義狀態圖的基本記號  展示狀態圖的建構  定義活動、內部事件及遞延事件的狀態 圖記號.
第二章 供給與需求 中興大學會計學系 授課老師:簡立賢.
: Fast and Easy Data Compressor ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10043: Fast and Easy Data Compressor 解題者:葉貫中 解題日期: 2007 年 3.
: Problem A : MiniMice ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11411: Problem A : MiniMice 解題者:李重儀 解題日期: 2008 年 9 月 3 日 題意:簡單的說,題目中每一隻老鼠有一個編號.
資料庫程式設計與系統管理 SQL Server 2005 Express 第六章 進階資料庫設計.
: Ahoy, Pirates! ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11402: Ahoy, Pirates! 解題者:李重儀 解題日期: 2008 年 8 月 26 日 題意:有一個海盜島有 N 個海盜,他們的編號 (id)
Distributed Video Coding. Outline Distributed video coding Lossless compression Lossy compression Low complexity video encoding Distributed image coding.
Fugacity Coefficient and Fugacity
: Multisets and Sequences ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11023: Multisets and Sequences 解題者:葉貫中 解題日期: 2007 年 4 月 24 日 題意:在這個題目中,我們要定義.
:Nuts for nuts..Nuts for nuts.. ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 10944:Nuts for nuts.. 解題者:楊家豪 解題日期: 2006 年 2 月 題意: 給定兩個正整數 x,y.
資料結構實習-一 參數傳遞.
6-2 認識元件庫與內建元件庫 Flash 的元件庫分兩種, 一種是每個動畫專 屬的元件庫 (Library) ;另一種則是內建元 件庫 (Common Libraries), 兩者皆可透過 『視窗』功能表來開啟, 以下即為您說明。
Management Abstracts Retrieval System; MARS 檢索操作.
Section 4.2 Probability Models 機率模式. 由實驗看機率 實驗前先列出所有可能的實驗結果。 – 擲銅板:正面或反面。 – 擲骰子: 1~6 點。 – 擲骰子兩顆: (1,1),(1,2),(1,3),… 等 36 種。 決定每一個可能的實驗結果發生機率。 – 實驗後所有的實驗結果整理得到。
函式 Function Part.2 東海大學物理系‧資訊教育 施奇廷. 遞迴( Recursion ) 函式可以「呼叫自己」,這種動作稱為 「遞迴」 此程式的執行結果相當於陷入無窮迴圈, 無法停止(只能按 Ctrl-C ) 這給我們一個暗示:函式的遞迴呼叫可以 達到部分迴圈的效果.
JAVA 程式設計與資料結構 第二十章 Searching. Sequential Searching Sequential Searching 是最簡單的一種搜尋法,此演 算法可應用在 Array 或是 Linked List 此等資料結構。 Sequential Searching 的 worst-case.
演算法 8-1 最大數及最小數找法 8-2 排序 8-3 二元搜尋法.
: Expect the Expected ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11427: Expect the Expected 解題者:李重儀 解題日期: 2008 年 9 月 21 日 題意:玩一種遊戲 (a game.
-Antidifferentiation- Chapter 6 朝陽科技大學 資訊管理系 李麗華 教授.
845: Gas Station Numbers ★★★ 題組: Problem Set Archive with Online Judge 題號: 845: Gas Station Numbers. 解題者:張維珊 解題日期: 2006 年 2 月 題意: 將輸入的數字,經過重新排列組合或旋轉數字,得到比原先的數字大,
Chapter 10 m-way 搜尋樹與B-Tree
演算法課程 (Algorithms) 國立聯合大學 資訊管理學系 陳士杰老師 Course 7 貪婪法則 Greedy Approach.
中央大學。范錚強 1 資料模式 Data Modeling 國立中央大學 資訊管理系 范錚強
2005/7 Linear system-1 The Linear Equation System and Eliminations.
5 重複迴圈 5.1 增減運算符號 增量運算符號 減量運算符號
ArcINFO &Geodatabase 由 ESRI 產生 1970 ArcINFO 一開始被設計在迷你電 腦上, 後來逐漸發展, 在 UNIX 系統上也能 執行, 直到今天, 已經可以在不同的平台上 運作.
SQL 進階查詢.
Teacher : Ing-Jer Huang TA : Chien-Hung Chen 2015/6/30 Course Embedded Systems : Principles and Implementations Weekly Preview Question CH7.1~CH /12/26.
著作權所有 © 旗標出版股份有限公司 第 3 章 資料庫物件的關係. 本章提要 Access 資料庫物件的關係 Access 資料庫物件的關係 簡介 Access 的七大物件 簡介 Access 的七大物件 Access 的群組 Access 的群組.
:Commandos ★★★☆☆ 題組: Contest Archive with Online Judge 題號: 11463: Commandos 解題者:李重儀 解題日期: 2008 年 8 月 11 日 題意: 題目會給你一個敵營區內總共的建築物數,以及建築物 之間可以互通的路有哪些,並給你起點的建築物和終點.
: Place the Guards ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11080: Place the Guards 解題者:陳盈村 解題日期: 2008 年 3 月 26 日 題意:有一個國王希望在他的城市裡佈置守衛,
: SAM I AM ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11419: SAM I AM 解題者:李重儀 解題日期: 2008 年 9 月 11 日 題意: 簡單的說,就是一個長方形的廟裡面有敵人,然 後可以橫的方向開砲或縱向開砲,每次開砲可以.
家庭社會工作 陳阿梅.
Introduction to Java Programming Lecture 16 Super and Sub Classes.
: Finding Paths in Grid ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11486: Finding Paths in Grid 解題者:李重儀 解題日期: 2008 年 10 月 14 日 題意:給一個 7 個 column.
Concept Map – whatwhat, why and how?whyhow. Outline.
幼兒行為觀察與記錄 第八章 事件取樣法.
Mapping - 1 Mapping From ER Model to Relational DB.
CH 14-可靠度工程之數學基礎 探討重點 失效時間之機率分配 指數模式之可靠度工程.
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 肆 資料分析與表達.
1 柱體與錐體 1. 找出柱體與錐體的規則 2. 柱體的命名與特性 3. 柱體的展開圖 4. 錐體的命名與特性 5. 錐體的展開圖
Entity-Relationship (ER) Data Model 概念資料模式 (Based on Chapter 3 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 4)
Introduction to Database System Wei-Pang Yang, IM.NDHU, Final Test-1 Example: Banking Database 1. branch 2. customer 客戶 ( 存款戶, 貸款戶 ) 5. account.
Software Engineering for Digital Home 單元 3 :軟體設計 Chapter 3-6 – Specifying Interfaces.
Bio Project 酶.
Presentation transcript:

Logical Design for the Relational Model Unit 10 Logical Design for the Relational Model 2018/11/27 Unit 10

本單元目的 把 model independent design 結果的資料庫概念架構轉為關聯資料庫管理系統可以描述的關聯資料庫 2018/11/27 Unit 10

Outlines An Introduction to the Relational Model Schema Mapping from the ER model to the Relational Model Elimination of external identifier Elimination of composite and multi-value attributes Translation of entities Translation of relationships Mapping the operations to SQL 2018/11/27 Unit 10

The Relational Model Schema : STUDENT(NAME, AGE, SEX) attribute Primary key tuple Data instances column Degree of a relation means the number of columns. Cardinality of a relation means the number of tuples. 2018/11/27 Unit 10

Mathematical definition for a relation A domain is a collection of values. D1={a,b} attribute A1 valued from D1 D2={c,d,e} attribute A2 valued from D2 Relation R 2018/11/27 Unit 10

Integrity rules Entity integrity Referential integrity R2 R1 PK R1 R2 Integrity rules FK Entity integrity No attribute participate in the primary key (PK) of a base relation is allowed to accept null values. Referential integrity If base relation R2 includes a foreign key (FK) matching the PK of some base relation R1, then every values of FK in R2 must either be equal to the value of PK in some tuple of R1 or be wholly null R1 and R2 are not necessarily distinct. 2018/11/27 Unit 10

Example of a relational data base NAME AGE STUDENT SEX EXAM GRADE CODE 和 COURSE_NUMBER 從同一個 domain 出來 STUDENT_NAME 和 NAME從同一個 domain 出來 CODE COURSE INSTRUC TOR EXAM(COURSE_NUMBER, STUDENT_NAME, GRADE) STUDENT(NAME, AGE, SEX) COURSE(CODE, INSTRUCTOR) 2018/11/27 Unit 10

Schema Mapping from the ER model to the Relational Model Steps: Elimination of external identifier Elimination of composite and multi-value attributes Translation of entities Translation of relationships Mapping the operations to SQL 2018/11/27 Unit 10

Elimination of external identifier E2 有 internal identifier E1 的 primary key 是由一個屬於 E1 的 attribute 加上 E2 形成 identifier, 是為 external identifier. 把 E2的 primary key 放入 E1 把 R 去掉, 因為 R 的關係已在 E1 中表示了 E1 R E2 b1 b2 b3 b4 a1 a2 E1 b1 b2 b3 b4 a1 a1 E2 a2 2018/11/27 Unit 10

Elimination of external identifier  去掉 external id 的動作要從 strong entity 動手, 把依附在該 strong entity 的 weak entity 放入該 strong entity 的 primary. 2018/11/27 Unit 10

Elimination of composite attribute (復合屬性) 合併好 還是拆開好? 合併 拆開 2018/11/27 Unit 10

加上原來的 primary key 變成另一個 entity Elimination of multi-value attributes 每個產品由多種材料組成 加上原來的 primary key 變成另一個 entity 2018/11/27 Unit 10

Elimination of multi-value attribute from a relationship by creating a separate entity If the relationship is one-to-one, NE includes the primary key of either E1 or E2. If the relationship between E1 and E2 is one-to-many, NE includes the primary key of E2 (assuming E2 is on the "many" side). If the relationship between E1. and E2, is many-to-many, NE includes the primary keys of both E1 and E2. NE c2 E1 b1 b2 b3 b1 or a1 NE a1 c2 R c2 a1 E2 a2 NE b1 a1 c2 2018/11/27 Unit 10

Example of multi-value attribute on a relationship  把 INSTRUCTOR 的 primary key 和 COURSE 的 primary key 加上原來在 Relationship 上的多重值 attribute 形成 另一個 entity. 2018/11/27 Unit 10

Translation of an entity 2018/11/27 Unit 10

Translation of one-to-one relationships Case 1: 當 relationship 兩邊的cardinality 都是 (1,1)時, 則合併為一個 relation. Case 2: 當 cardinality 顯示有一 entity在relationship 發生的情況是 partial 時, 則宜獨立另一 relation. 2018/11/27 Unit 10

Translation of one-to-one relationships Case 3: 當兩邊 cardinality 發生的情況是皆 partial 時, 則宜獨立另一 relation, 用兩邊相連 entities 之 primary key attribute加起來當作新成立的 relation primary key. MALE ( MALE_SSN, NAME ) FEMALE ( FEMALE_SSN, NAME ) MARRIAGE ( MALE_SSN, FEMALE_SSN, DATE, DURATION ) 2018/11/27 Unit 10

Translation of one-to-many relationships Case 1: Total participation  把 one 那端的 primary key 加入 many 那端的 entity 中 CITY(CITY_NAME, STATE_NAME, POPULATION) STATE(STATE_NAME, GOVERNOR, POPULATION) 2018/11/27 Unit 10

Translation of one-to-many relationships Case 2: Partial participation  因為 ORDER的建立若和 SALEMAN有關連,則可有 DISCOUNT_RATE, 亦可能和 SALESMAN無關連。 Alternative 1: SALESMAN(NAME, PHONE_NO) ORDER(ORDER_NO, DATE, SALESMAN_NAME, DISCOUNT_RATE) Alternative 2: SALESMAN(NAME, PHONE_NO) ORDER(ORDER_NO, DATE) SALES_ORDER(ORDER_NO, SALESMAN_NAME, DISCOUNT_RATE) 2018/11/27 Unit 10

Translation of many-to-many relationships  把STUDENT的 primary key 加上 COURSE的 primary key 加上 ENROLLED_IN 的 attributes 形成另一個 entity STUDENT(STUDENT_NUMBER, LAST_NAME, GPA) COURSE(COURSE_NUMBER, COURSE_NAME) ENROLLED_IN(STUDENT_NUMBER, COURSE_NUMBER, SEMESTER, GRADE) 2018/11/27 Unit 10

Translation of ternary relationships (三元關係)  把三個 entity 的 primary key 加上 relationship 的 attributes 形成另一個 entity 2018/11/27 Unit 10

Translation of quaternary relationships (四元關係) CAR_SALE(CAR_NO, CUST_NAME, DEALER_NAME, BANK_NAME, CAR_PRICE, LOAN_AMOUNT, INTEREST_RATE) 新建的 relation 要取 minimal primary key set 例如: 若 CAR_NO CUST_NAME 則 CUST_NAME 可以不在 primary key set 中 2018/11/27 Unit 10

Translation of recursive relationships (遞迴關係) Many-to-many relationship: EMPLOYEE(NAME, DATE_OF_BIRTH) MANAGER_OF(NAME_OF_MANAGER, NAME_OF_SUBORDIINATE) One-to many relationship: MANAGER_OF(NAME_OF_SUBORDINATE, NAME_OF_MANAGER) or EMPLOYEE(NAME, DATE_OF_BIRTH, NAME_OF_MANAGER) 較理想 2018/11/27 Unit 10

Mapping the operations to SQL 找單一entity資料時, FROM 單一entity_name 透過另一 entity 時, 經過的 entity name 出現在 FROM 後面 條件出現在 WHERE子句 GROUP BY and HAVING 子句在 navigation schema 看不出, 要在 SQL 加入. join condition 要找的 attributes 經過的 entity SELECT A4, A5, A6 FROM E1, E2, E3 WHERE jc1 and jc2 and COND(A1,A2,A3) 條件 2018/11/27 Unit 10

Example of translating navigation schema to SQL ER schema : Q1: 找出年齡小於 30 的 instructors Relation schema: INSTRUCTOR(SSN, NAME, AGE) OFFERS(SSN, COURSE_NAME, SEMESTER, MAX_NO_STUD) COURSE(COURSE_NAME, DEPARTMENT) 2018/11/27 Unit 10

Example of translating navigation schema to SQL Q2: 給某老師的 SSN, 找出他所開的課程所屬的 department. Alternative 1: SELECT DEPARTMENT FROM COURSE WHERE COURSE_NAME IN SELECT COURSE_NAME FROM OFFERS WHERE SSN=$X Alternative 2: SELECT DEPARTMENT FROM COURSE, OFFERS WHERE COURSE, COURSE_NAME =OFFERS.COURSE_NAME AND SSN=$X 2018/11/27 Unit 10

Exercises 1. Consider the following ER diagram of a database for a city's traffic and parks departments. Draw navigational schemas in ER form for the following queries: (1) List all street names in a given city. (2) List all intersections on Main street in the city of Gainesville, Georgia. (3) List all parks in the city of Gainesville, Florida. (4) List all parks located on Huron Street in Ann Arbor, Michigan. Proceed as follows: a.  First convert the ER model to a relational database. b.  Convert the above navigation schemas into SQL. 2018/11/27 Unit 10

2. Consider the following ER schema of the airport and flights database. Convert it into a set of relations. Point out all referential constraints among the relations. 2018/11/27 Unit 10