SlideShare une entreprise Scribd logo
1  sur  24
DB Introduction to
Databases
Speaker:張憲騰
Introduction
• Database Management System(DBMS)
• Relational Model
• XML
DBM
S
efficien
t
Saf
e convien
ce
Persisten
t data massi
ve
Multi-
User
reliabl
e
Relational Model
• 非常簡單的model
• 使用的語言超級高階:Simple yet expressive
• 極度有效可以實施
• 使用率極高:主流的商業DBMS
ID Name GPA College
C44011257 Sam 3.5 NCKU
H33014542 John 3.1 NTU
H45143215 Amy 3.3 Stanford
D31545344 Angelababy 3.8 MIT
她長這樣
• Table Student
Name State Enr(NTD)
NCKU Tainan 4,5000
NTU Taipei 50,000
Stanford CA 1,500,000
MIT CA 2,000,000
• Table College
關聯式模型是將資料庫表示成一個由許多關聯(Relation)
所組成的集合。
非正式的說,每個關聯就像一個表格。
每一個關聯 (表格) 包含了很多列(Row)與欄(Column)
聯式模型的正式術語(formal terminology)
一個關聯R在資料庫中,是由兩個部份組成:
表頭(Heading)
„由一定數目的屬性集合 (Attribute Set) 及各屬性之定義域
(Domain) 所組成,用來表示關聯中的所有屬性。
主體(Body)
„由值組 (Tuple) 的集合所組成,用來記錄關聯中的資料部份。
會隨著時間變動
ID Name GPA College
C44011257 Sam 3.5 NCKU
H33014542 John 3.1 NTU
H45143215 Amy 3.3 Stanford
D31545344 Angelababy 3.8 MIT
Tuple
Attribute
„定義域 (Domain)
 是由某種資料型態或資料格式之所有可能值所構成的集合
 Student這個關聯表格的GPA,該欄位的定義域可能為:0~4
屬性 (Attribute)
 為某個定義域所扮演的角色,又可稱為欄 (Column, Field)。
值組 (Tuple)
 為某個屬性的值,又可稱為列 (Row, Record)。
ID Name GPA College
C44011257 Sam 3.5 NCKU
H33014542 John 3.1 NTU
H45143215 Amy 3.3 Stanford
D31545344 Angelababy 3.8 MIT
Q&A
關聯的特性 (Characteristics Of Relations)
Tuple,Attributes之間沒有次序性 (Order)
實際應用上,User是可以指定關聯表格中所有的次序,但非絕
對必要。
一個關聯中,不含重複的tuple
(?)問問大家
所有Attribute值皆為基元值 (Atomic Value)
„不可再分解的值,或是分解後不具任何意義的值。
„又稱簡單值(Simple Value)、純量值(Scalar Value)
„有些欄位的值是否為Atomic可以由User決定,有些則不可以。
Ex: 姓名 (可以),生日 (可以),學號 (不可以),性別 (不可以)…
等。
(?)問問大家
空值(Null)
Special value for unknown or undefined
鍵值(key)
http://sjchen.im.nuu.edu.tw/Database/98/Ch02.pdf
創造和使用資料庫
Data
Query languages
Relational Algebra
Formal
SQL
Implemented
差在哪??看黑板
XML(Extensible Markup Language)
可擴展標記語言
• 格式很像HTML(XML用來傳送資料,HTML用
來表現資料)
• 樹狀排列
• 易讀性高
• 支援眾多軟體
XML結構
<?xml version="1.0"?>
<小紙條>
<收件人>大元</收件人>
<發件人>小張</發件人>
<主題>問候</主題>
<具體內容>早啊,飯吃了沒? </具體內容>
</小紙條>
Basic structure:
• 嵌套元素(Tagged elements)
• Attribute
• Text
Relational Model XML
Structure Table Hierarchical, Tree,
graph
Schema Fixed in advance Flexible
“Self-describing”
Query Simple, nice
Language
Less so
Ordering None Implied
Implementation Native Add-on
XML versus Relational Model
Q&A
Q1:
A database to contain information about university records:
students, courses, grades, etc.
Should you use the relational model or XML?
Q2:
A database to contain information for a university web site:
news, academic announcements, admissions, events, research,
etc.
Should you use the relational model or XML?
Well Formed的XML 文檔遵守的語法規則:
• XML 文檔必須有根元素
• XML 文檔必須有關閉標籤
• XML 標籤對大小寫敏感
• XML 元素必須被正確的嵌套
• XML 屬性必須加引號
Well-formed XML vs. Valid XML
Valid的XML 文檔遵守的語法規則:
遵守DTD和XSD的架構特定規範和內容特定規範
XML 文件
Validation XML
parser
Parsed
XML
DTD
XSD
DTD(Document Type Definition)
為什麼使用DTD?
• 統一格式:
通過DTD,您的每一個XML文件均可攜帶一個有關其自身格
式的描述。
• 方便交換:
通過DTD,獨立的團體可一致地使用某個標準的DTD 來交換
數據。
• 方便驗證:
而您的應用程序也可使用某個標準的DTD 來驗證從外部接
收到的數據。
您還可以使用DTD來驗證您自身的數據。
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Don't forget the meeting!</body> </note>
DTD鍵塊模組
XML鍵塊模組:
• 元素
• 屬性
• 實體
• PCDATA:
會被解析器解析的文本。
• CDATA:
不會被解析器解析的文本。
http://www.w3school.com.cn/dtd/
dtd_attributes.asp
DTD屬性

Contenu connexe

En vedette

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

En vedette (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Db1