第1章 資料庫系統的基礎觀念
Download
Report
Transcript 第1章 資料庫系統的基礎觀念
概念建模(conceptual modeling)是什麼 ?
資料模型(data model)是什麼 ?
資料模型有什麼用?
這是一個腦力激盪的園地!
物質是由於原子與分子構成的,原子與原子之間
可以透過鍵結形成分子,性質跟原來的組成原子
不同
原子鍵結形成分子的方式也稱為分子模型,相同
的原子組合在不同的分子模型下會鍵結成不同的
物質
資料模型跟分子模型很像,原始資料就是原子,
透過資料模型形成資料物件,對應到現實世界的
事與物
描述資料的表示法。
處理資料的一組操作(operations) 。
資料模型(data model)是資料抽象化的基礎,
我們可以把資料模型定義成描述資料庫結構
的各種觀念,而資料庫的結構則包括資料的
型式、資料之間的關係,以及資料的限制
(constraints) 。
目的與用途。
以物件(object)還是以值(value)為主。
資料重複(redundancy)問題的處理。
多對多(many-many)關係的處理。
概念式的資料模型(conceptual data model)
實體資料模型(physical data model)
實作資料模型(implementation data model)
internal schema 內部
conceptual schema 概念
external schema 外部
three-schema architecture可以用來解
釋資料獨立性(data independence)的觀
念,主要的關鍵在於我們能在不同的層
次(level)上改變對應的schema,而不會
影響其他層次上的schema。
High-level data Model
Physical data Model
E-R Model
Record-based
Data Model
logical data independence 邏輯
Conceptual External
概念變動不影響外部
physical data independence 實體
Internal Conceptual
內部變動不影響概念
階層式資料模型 Hierarchical Data Model
parent record type 上層
child record type 下層
網路資料模型 Network Data Model
set type 集合型態
Owner record type
Member record type
階層式的資料模型使用記錄(records)與階層關係
(parent-child relationships)的觀念
記錄是欄位值(field values)的組合,記錄的型式
(record types)定義了記錄中所含有的欄位,每
個欄位則有個別的資料型式(data type)
階層關係是兩種record types之間的1:N
relationship,1的那一邊是parent record type,
N的那一邊是child record type
網路資料模型可以看成是一種 E-R model,但是
relationships限於binary relationship,而且是
many-one relationship
網路資料模型使用記錄(records)與集合(sets)的觀念。
資料儲存在records中,每個record包含一些相關的
資料值
Records之間的關係用Set Type來表示。一個集合型
式(set type)描述一種records之間的1:N relationship,
我們可以使用所謂的Bachman diagram來畫出set
type定義中的組成 : set type的名稱、record type的
owner與member record type
EMPS (ENAME, SALARY)
DEPTS(DNAME, DEPT#)
SUPPLIER(SNAME, SADDR)
ITEMS(INAME, ITEM#)
ORDERS(O#, DATE)
CUSTOMERS(CNAME, CADDR, BALANCE)
個體(entity)
屬性(attributes)
Simple attributes與Composite attributes
Single-valued attributes與multivalued attributes
Stored attributes與derived attributes
鍵,Key attribute, Composite key,識別用
加底線
關係(relationship)
二元關係(binary relationship)
數量(cardinality)
一對一、一對多、多對多
LAST
NAME
FIRST
NAME
Composite Attribute
複合屬性
NAME
BIRTHDATE
AGE
Derived Attribute
衍生屬性
TEL NO.
Multi-value Attribute
多重值屬性
PERSONS
SSN
Key Attribute
鍵屬性
PARENT
OF
XML(eXtensible Markup Language)已經成為一
種大家公認的標準文件格式(standard document
format),有利於文件資料的交換與顯示
很多研究都嘗試著替XML發展出正規的資料模
型,有了正規的資料模型以後,可以發展出一些
查詢語言與處理的機制
實體模型(physical model)
正規模型(formal model)
概念模型
實體模型與實作(implementation)有關,層次最
低,要處理資料結構以及資料探索(navigation)
的細節
正規模型需要語言層次的元素來對資料進行推理
概念模型的主要目的是用來了解資料
DOM(Document Object Model)
XML資料模型
XSLT, Xquery, XPath
檔案型式的結構化資料
XML Schema
OEM(Object Exchange Model)
複雜物件(complex object)的資料庫模型
XGrammar
SAL代數模型(algebraic model)
Semi-structured Algebra
UML
ERX(Entity Relationship for XML)
UML(unified modeling language)是一種描述軟
體系統的標準化建模語言,UML也具有一般資
料模型的描述能力,但是除了描述應用系統的資
料特性之外,還可以從其他方面來描述一個應用
系統
關聯式資料模型(relational data model)
物件導向資料模型(object-oriented data model)
物件-關聯式資料模型(object-relational data
model)
畫一個 ER Diagram 描述下列需求
每一位學生都必須屬於某一個班級
每一個班級都有一位導師
一位老師最多可以擔任兩個班級的導師,但是也可以
不擔任導師
請注意,每一個Entity都應該要有Key