Introduction to Database System Wei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1 Example: Banking...

11
Introduction to Database System Wei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1 Example: Banking Database 1. branch 2. customer 客客 ( 客客客 , 客客客 ) 5. account 客客客 3. depositor 客客客 6. loan 客客客 4. borrower 客客客 客客客 國國國國國國國國 : 國國國國國 客客客客 客客 2012.06.19

Transcript of Introduction to Database System Wei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1 Example: Banking...

Page 1: Introduction to Database System Wei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1 Example: Banking Database 1. branch 2. customer 客戶 ( 存款戶, 貸款戶 ) 5. account.

Introduction to Database SystemWei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1

Example:Banking Database

1. branch 2. customer客戶 ( 存款戶 , 貸款戶 )

5.

account

存款帳

3. depositor 存款戶

6. loan 貸款帳 4. borrower 貸款戶

分公司

國立東華大學試題 : 資料庫管理 資訊管理學系 2012.06.19

Page 2: Introduction to Database System Wei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1 Example: Banking Database 1. branch 2. customer 客戶 ( 存款戶, 貸款戶 ) 5. account.

Introduction to Database SystemWei-Pang Yang, IM.NDHU, 2010

Question 1: Terms Explanation (20%)

1) Logical Database Design

2) Update Anomalies

3) Minimize the number of Disk Access

4) Weak Entity

5) Draw the Functional Dependency Diagram for table account in page 1.

6) Total participator vs. Partial participator in ER-Model

7) Many-to-Many Relationship Set

8) blob: binary large object

9) foreign key (branch-name) references branch on delete cascade

10) Generalization vs. Specialization

2012 Final Test-2

Page 3: Introduction to Database System Wei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1 Example: Banking Database 1. branch 2. customer 客戶 ( 存款戶, 貸款戶 ) 5. account.

Introduction to Database SystemWei-Pang Yang, IM.NDHU, 2010

Question 2: Real-world vs. E-R Model vs. Tables (10%)

1. branch 2. customer 客戶 ( 存款戶 , 貸款戶 ) 3. depositor 存款戶分公司

Semantic Data Model:

Entity-Relationship (E-R) Data Model

The real-world enterprise

試討論 Real-world, E-R Model , 及 Tables 之關係

2012 Final Test-3

Page 4: Introduction to Database System Wei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1 Example: Banking Database 1. branch 2. customer 客戶 ( 存款戶, 貸款戶 ) 5. account.

Introduction to Database SystemWei-Pang Yang, IM.NDHU, 2010

Question 3: 1NF 2NF (10%)

S# STATUS CITY

S1 20 London S2 10 Paris S3 10 Paris S4 20 London S5 30 Athens

SECOND

S# P# QTY) S1 P1 300 S1 P2 200 S1 P3 400 S1 P4 200 S1 P5 100 S2 P1 300 S2 P2 400 S3 P2 200 S4 P4 300 S4 P5 400

SP

S# STATUS CITY P# QTY

S1 20 London P1 300 S1 20 London P2 200 S1 20 London P3 400 S1 20 London P4 200 S1 20 London P5 100 S1 20 London P6 100 S2 10 Paris P1 300 S2 10 Paris P2 400 S3 10 Paris P2 200 S4 20 London P2 200 S4 20 London P4 300 S4 20 London P5 400

FIRST

從下面幾點討論把 FIRST 拆成 SECOND 及 SP 的好處 :

1) Update? S1 moves from London to Paris

2) Insertion: (S5 30 Athens)

3) Delete "S3 supplies P2 200",

2012 Final Test-4

Page 5: Introduction to Database System Wei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1 Example: Banking Database 1. branch 2. customer 客戶 ( 存款戶, 貸款戶 ) 5. account.

Introduction to Database SystemWei-Pang Yang, IM.NDHU, 2010

Question 4: 2NF 3NF (10%)

S# STATUS CITY

S1 20 London S2 10 Paris S3 10 Paris S4 20 London S5 30 Athens

SECOND (in 2NF)

1) SECOND 還有缺點嗎 ?

2) SECOND 是 3NF 嗎 ? Why?

從下面幾點討論把 SECOND 拆成 CS 及 SC 的好處3) Update

4) Insertion

5) Delete

CITY STATUS

Athens 30 London 20 Paris 10 Rome 50

CS (in 3NF) SC (in 3NF)

S# CITY S1 London S2 Paris S3 Paris S4 London S5 Athens

2012 Final Test-5

Page 6: Introduction to Database System Wei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1 Example: Banking Database 1. branch 2. customer 客戶 ( 存款戶, 貸款戶 ) 5. account.

Introduction to Database SystemWei-Pang Yang, IM.NDHU, 2010

Consider the Supplier table, S. 假設 Index 整個放在一個 page, S Table 每一筆 tuple 各放一個 page

S1

S2

S3

S4

S5

Smith

Jones

Blake

Clark

Adams

20

10

30

20

30

London

Paris

Paris

London

Athens

City-Index (index)

Athens

London

London

Paris

Paris

S (indexed file)

Question 5: Indexing (10%)

1) 要列印所有住在 “ Athens” 的 Supplier’s Name, 需多少 Disk I/O? 解釋之。2) 要列印所有住在 “ London” 的 Supplier’s Name, 需多少 Disk I/O? 解釋之。3) 要列印所有住在 “ Taipei” 的 Supplier’s Name, 需多少 Disk I/O? 解釋之。4) 若插入 “ S6 Yang 25 Hualien”, 重畫 S 及 City-Index 二 Tables.

5) 如果沒有 City-Index, 要列印所有住在 “ London” 的 Supplier’s Name, 需多少Disk I/O? 解釋之。

2012 Final Test-6

Page 7: Introduction to Database System Wei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1 Example: Banking Database 1. branch 2. customer 客戶 ( 存款戶, 貸款戶 ) 5. account.

Introduction to Database SystemWei-Pang Yang, IM.NDHU, 2010

Question 6: B+-tree (10%)

50 82

96 97 9991 93 94

89 94

83 85 8971 78 8260 62 7051 52 58

58 70

35 40 5015 18 326 8 12

12 32

index set

Sequence set (with pointers to data records)

-

1) B+ tree 如何提供 “ fast direct access” 的服務 ? 以找 key= “62” 為例說明

2) B+ tree 如何提供 “ fast sequential access” 的服務 ?

3) 若一個 node 可放 100 key 時,第三層共可放幾個 key?

4) Sequence set (with pointers to data records) 是什麼意思 ?2012 Final Test-7

Page 8: Introduction to Database System Wei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1 Example: Banking Database 1. branch 2. customer 客戶 ( 存款戶, 貸款戶 ) 5. account.

Introduction to Database SystemWei-Pang Yang, IM.NDHU, 2010

According to your final project as “Design and implement a useful database application system”

1) What is the title of your project?

2) Names of members in your team.

3) Draw the E-R Diagram of your application system. (You can just give a similar diagram.)

4) Draw a table to show one relation used in the system

5) Check your answer in d) to see whether it is in the 1NF? Why? Please answer “why” by using the definition of the 1NF.

6) Same as e) to see whether it is in the 2NF? Why?

7) Same as e) to see whether it is in the 3NF? Why?

Question 7: About Your Final Term Project (10%)

2012 Final Test-8

Page 9: Introduction to Database System Wei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1 Example: Banking Database 1. branch 2. customer 客戶 ( 存款戶, 貸款戶 ) 5. account.

Introduction to Database SystemWei-Pang Yang, IM.NDHU, 2010

Host

Language

+ DSL

Host

Language

+ DSL

Host

Language

+ DSL

Host

Language

+ DSL

Host

Language

+ DSL

User A1 User A2 User B1 User B2 User B3

External View

@ # &

External View

B

External/conceptualmapping A

Conceptual

View

External/conceptualmapping B

Conceptual/internalmapping

Stored database (Internal View)

Database

management

system dictionary

(DBMS) e.g. system

catalog

<

DBA

Storagestructuredefinition(Internalschema)

Conceptualschema

ExternalschemaA

ExternalschemaB

(Build andmaintainschemasandmappings)

# @&

DSL (Data Sub Language)

C, Pascal

e.g. SQL1 2 3

1 2 3 ... 100

Question 8: 儘量解釋右圖 (10%) 第 8 、 9 、 10

任選二題做答

2012 Final Test-9

Page 10: Introduction to Database System Wei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1 Example: Banking Database 1. branch 2. customer 客戶 ( 存款戶, 貸款戶 ) 5. account.

Introduction to Database SystemWei-Pang Yang, IM.NDHU, 2010

Major System Components: DB2 SourceModule

ModifiedSourceModule

DBRM

Object

Module

Load

Module

Application

Plan

PL/I-Compiler Bind

Pre-compiler

Linkage

Editor (Load Module)

(Application Plan)

Runtime Supervisor

Data Manager

Buffer Manager

(Other)

DB

PL/I + SQL:EXEC SQL CREATE TABLE S ( S# CHAR(5), ......)EXEC SQL SELECT SNAME INTO :SNAME FROM SIF SQLCODE < 0 THEN .......

CALL CREATE( ......)CALL SELECT( ......)IF SQLCODE < 0 THEN .......

PL/I source

parse-tree version

of SQL

request

module

a DB Compiler

optimized machine

codes of SQL statements

in system Catalog

1

2 33'

4

1st time

1. Pre-compiled2. Bind3. Runtime Supervisor4. Data Manager5. Buffer Manager

Question 9: 儘量解釋下圖 (10%)

第 8 、 9 、 10任選二題做答

2012 Final Test-10

Page 11: Introduction to Database System Wei-Pang Yang, IM.NDHU, 2010 2012 Final Test-1 Example: Banking Database 1. branch 2. customer 客戶 ( 存款戶, 貸款戶 ) 5. account.

Introduction to Database SystemWei-Pang Yang, IM.NDHU, 2010

DB2’s Major System Components: Execution time

Runtime

Supervisor

Application

Plan

( for P )

Stored

Data

Manager

If -

-

CALL

-

Catalog or Dictionary

"data about data"

Database

"data"

Buffer

Manager

PL / 1 LOAD MODULE P

Question 10: 儘量解釋下圖 (10%)

第 8 、 9 、 10任選二題做答

2012 Final Test-11