megatran-3000-class-2-part2 (1)
TRANSCRIPT
![Page 1: Megatran-3000-class-2-part2 (1)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/1.jpg)
1
Implementation of
Database System
Introduction
Omar Aldawud
![Page 2: Megatran-3000-class-2-part2 (1)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/2.jpg)
2
Isn’t Implementing a Database
System Simple?
Relations Statements Results
![Page 3: Megatran-3000-class-2-part2 (1)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/3.jpg)
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)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/4.jpg)
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)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/5.jpg)
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)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/6.jpg)
6
Megatron 3000
Sample Sessions
% MEGATRON3000
Welcome to MEGATRON 3000!
&
& quit
%
.
.
.
![Page 7: Megatran-3000-class-2-part2 (1)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/7.jpg)
7
Megatron 3000
Sample Sessions
& select *
from R #
Relation R
A B C
SMITH 123 CS
&
![Page 8: Megatran-3000-class-2-part2 (1)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/8.jpg)
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)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/9.jpg)
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)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/10.jpg)
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)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/11.jpg)
Result sent to LPR (printer)
Megatron 3000
& select *
from R | LPR
&
![Page 12: Megatran-3000-class-2-part2 (1)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/12.jpg)
New relation T created.
Megatron 3000
select *
from R
where R.A < 100 | T #
&
![Page 13: Megatran-3000-class-2-part2 (1)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/13.jpg)
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)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/14.jpg)
WHAT’S WRONG WITH THE
MEGATRON 3000 DBMS?
![Page 15: Megatran-3000-class-2-part2 (1)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/15.jpg)
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)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/16.jpg)
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)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/17.jpg)
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)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/18.jpg)
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)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/19.jpg)
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)](https://reader034.vdocument.in/reader034/viewer/2022051501/577cc3e71a28aba7119784eb/html5/thumbnails/20.jpg)
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