megatran-3000-class-2-part2 (1)

20
1 Implementation of Database System Introduction Omar Aldawud

Upload: sanapala-amit

Post on 19-Jul-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Megatran-3000-class-2-part2 (1)

1

Implementation of

Database System

Introduction

Omar Aldawud

Page 2: Megatran-3000-class-2-part2 (1)

2

Isn’t Implementing a Database

System Simple?

Relations Statements Results

Page 3: Megatran-3000-class-2-part2 (1)

3

Introducing the

Database Management System

• The latest from Megatron Labs • Incorporates latest relational technology • UNIX compatible

Page 4: Megatran-3000-class-2-part2 (1)

4

Megatron 3000 Implementation

Details

Relations stored in files (ASCII)

e.g., relation R is in /usr/db/R

Smith # 123 # CS

Jones # 522 # EE

.

.

.

Page 5: Megatran-3000-class-2-part2 (1)

5

Megatron 3000 Implementation

Details

Directory file (ASCII) in /usr/db/directory

R1 # A # INT # B # STR …

R2 # C # STR # A # INT …

.

.

.

Page 6: Megatran-3000-class-2-part2 (1)

6

Megatron 3000

Sample Sessions

% MEGATRON3000

Welcome to MEGATRON 3000!

&

& quit

%

.

.

.

Page 7: Megatran-3000-class-2-part2 (1)

7

Megatron 3000

Sample Sessions

& select *

from R #

Relation R

A B C

SMITH 123 CS

&

Page 8: Megatran-3000-class-2-part2 (1)

8

Megatron 3000

Sample Sessions

& select A,B

from R,S

where R.A = S.A and S.C > 100 #

A B

123 CAR

522 CAT

&

Page 9: Megatran-3000-class-2-part2 (1)

9

Megatron 3000

To execute “select * from R where condition”:

(1) Read directory file to get R attributes

(2) Read R file, for each line:

(a) Check condition

(b) If OK, display

Page 10: Megatran-3000-class-2-part2 (1)

10

Megatron 3000

To execute “select A,B from R,S where condition”:

(1) Read dictionary to get R,S attributes

(2) Read R file, for each line:

(a) Read S file, for each line:

(i) Create join tuple

(ii) Check condition

(iii) Display if OK

Page 11: Megatran-3000-class-2-part2 (1)

Result sent to LPR (printer)

Megatron 3000

& select *

from R | LPR

&

Page 12: Megatran-3000-class-2-part2 (1)

New relation T created.

Megatron 3000

select *

from R

where R.A < 100 | T #

&

Page 13: Megatran-3000-class-2-part2 (1)

To execute “select * from R where condition | T” :

• (1) Process select as before

• (2) Write results to new file T

• (3) Append new line to dictionary

Megatron 3000

Page 14: Megatran-3000-class-2-part2 (1)

WHAT’S WRONG WITH THE

MEGATRON 3000 DBMS?

Page 15: Megatran-3000-class-2-part2 (1)

15

What’s wrong with the Megatron

3000 DBMS?

Expensive update and search e.g., - To locate an employee with a given SSN,

- file scan.

- To change “Cat” to “Cats”, • complete file write.

• ASCII Storage is expensive

• Deletions are expensive

Page 16: Megatran-3000-class-2-part2 (1)

16

What’s wrong with the Megatron

3000 DBMS?

Search expensive; no indexes

e.g., - Cannot find tuple with given key quickly

- Always have to read full relation

• Solution: Indexing!

Page 17: Megatran-3000-class-2-part2 (1)

17

What’s wrong with the Megatron

3000 DBMS?

Brute force query processing e.g., select *

from R,S

where R.A = S.A and S.B > 1000

- Do select first?

- More efficient join?

• Solution: Query optimization!

Page 18: Megatran-3000-class-2-part2 (1)

18

What’s wrong with the Megatron

3000 DBMS?

No concurrency control or reliability

e.g., - if two client programs read your bank balance ($5000) and add $1000 to it…

- Crash.

• Solution: Transaction management!

Page 19: Megatran-3000-class-2-part2 (1)

19

What’s wrong with the Megatron

3000 DBMS?

No buffer manager

e.g., Need caching

• Solution: Buffer it!

Page 20: Megatran-3000-class-2-part2 (1)

20

What’s wrong with the Megatron

3000 DBMS?

No reliability

• e.g., - Can lose data

• - Can leave operations half done

No security

• e.g., - File system insecure

• - File system security is coarse

No application program interface (API)

• e.g., How can a payroll program get at the data?

Cannot interact with other DBMSs.

Poor dictionary facilities

No GUI