COMP2411 - Database System

A. ER Diagram


1. ER Digram

er_symbol

 

2. Cardinality Notation

1).

 

2). Some Examples

er_1

3. (Min, Max) Notation

1). Transfer to Sentence

min_max_n_ex1

---> There have 1 or more employee manges 1 department

---> Each department have 1 or more employee

min_max_n_ex2

---> One or more employee work for one department

---> One department have many employee

 

2). Some Examples

er_2

er_3

 

B. Relation Schema


1. Relation Key Types

2. Relation Schema (Table or Bruckets)

3. ER Diagram to Relation Schema

(Warning: Need to include both relation and entity ! ! !)

 

C. SQL (Oracle)


1. SQL Query

 

2. SQL to Sentence

 

D. Relational Algebra


1. SELECT σ & PROJECT π operations

2. Set Operations

o_example

 

3. (INNER) JOIN Operations

join_operations_1

 

 

4. SQL to Relational Algebra

 

E. Compatibility Mode


1. Normal Forms

 

F. File Organization & Indexs & Data Structure in DBMS


1. Disk Storage Devices

disk_storage_devices_1

2. Files of Records

1). Operations on Files

 

2). Unordered Files & ordered Files

4). Hash File

hashed_files_1

5). Dynamic & Extendible Hash

hashed_files_2

 

3. Indexes as Access Paths

BFR = Block Size / Record Size

number of index blocks b = r / (Block Size / Record Size)

Avg Linear Search = (b/2)= 10000/2= 5000 block accesses

Block Access:

Binary search needs log2b = log2938= 10 block accesses +1 get file block = 11 block accesses

 

4. Types of Single-level Indexes

 

5. Multi-level Indexes

Example

muti_level_indexing

6. B Tree & B+ Tree

 B TreeB+ Tree
DifferencePointers to data records exist at all levels of the treeAll pointers to data records exists at the leaf-level nodes
Exampleb_tree_example_1b_plus_tree_example_1
InsertionN/Ab_plus_tree_insertion
DeletionN/Ab_plus_tree_deletion

 

G. Tuning in Relational DBMS

1. Goal

2. Tuning Indexes

3. Tuning Queries

 

 

H. Transactions and Concurrency Control

1. Transaction

1). Property of Transaction

2). States of Transaction

State_Transition_Diagram

Recovery manager

Use: undo & redo

Track:

3). Transaction Schedule

Example:

LabelTransaction
T1w1(x), r1(y), w1(y)
T2r2(x), r2(y), w2(y)
-->w1(x), r2(x), r1(y), w1(y), r2(y), w2(y)

4). Schedules Classified on Recoverability

Cascadeless-and-Strict-Schedule

 

5). Schedules Classified on Serializability

2. Concurrency

1). Concurrency Control

2). Two-Phase Locking Techniques