Download presentation
Presentation is loading. Please wait.
1
CPSC-608 Database Systems
Fall 2018 Instructor: Jianer Chen Office: HRBB 315C Phone: Notes #11
2
Graduate Database DBMS lock table DDL language DDL complier file
administrator DDL complier lock table DDL language file manager logging & recovery concurrency control transaction manager database programmer index/file manager buffer manager query execution engine DML complier main memory buffers DML (query) language secondary storage (disks) DBMS Graduate Database
3
Graduate Database DBMS lock table DDL language DDL complier file
administrator DDL complier lock table DDL language file manager logging & recovery concurrency control transaction manager database programmer index/file manager buffer manager query execution engine DML complier main memory buffers DML (query) language secondary storage (disks) DBMS Graduate Database
4
Two-phase Multiway MergeSort
disk read/write: 40 ms a tuple: 160 bytes a block: 16KB (100 tuples) a relation R: 1.6 GB (10M tuples, 100K blocks) main memory: 100MB (6400 blocks) Two-phase Multiway MergeSort Phase 1. making sorted sublists repeat fill the main memory with remaining tuples in R and sort them; write the sorted sublist (of 6400 blocks) back to disk Phase 2. Merging bring in a block from each of the sorted sublist; merge them and put in an “output” block; write the “output” block back to disk when it is full
5
Two-phase Multiway MergeSort
Main memory Two-phase Multiway MergeSort Disk
6
Two-phase Multiway MergeSort
First Phase Main memory Two-phase Multiway MergeSort Disk
7
Two-phase Multiway MergeSort
First Phase Sort it Main memory Two-phase Multiway MergeSort Disk
8
Two-phase Multiway MergeSort
First Phase Main memory Two-phase Multiway MergeSort Disk
9
Two-phase Multiway MergeSort
First Phase Main memory Two-phase Multiway MergeSort Disk
10
Two-phase Multiway MergeSort
First Phase Sort it Main memory Two-phase Multiway MergeSort Disk
11
Two-phase Multiway MergeSort
First Phase Main memory Two-phase Multiway MergeSort Disk
12
Two-phase Multiway MergeSort
First Phase Main memory Two-phase Multiway MergeSort Disk
13
Two-phase Multiway MergeSort
First Phase Sort it Main memory Two-phase Multiway MergeSort Disk
14
Two-phase Multiway MergeSort
First Phase Main memory Two-phase Multiway MergeSort Disk
15
Two-phase Multiway MergeSort
First Phase Main memory Two-phase Multiway MergeSort Disk
16
Two-phase Multiway MergeSort
First Phase Sort it Main memory Two-phase Multiway MergeSort Disk
17
Two-phase Multiway MergeSort
First Phase Main memory Two-phase Multiway MergeSort Disk
18
Second Phase Main memory Disk
19
Two-phase Multiway MergeSort
Second Phase Main memory One block per sublist Two-phase Multiway MergeSort Disk
20
Two-phase Multiway MergeSort
Main memory One block per sublist Two-phase Multiway MergeSort Disk
21
Two-phase Multiway MergeSort
Main memory One block per sublist Two-phase Multiway MergeSort Disk
22
Two-phase Multiway MergeSort
Main memory One block per sublist Two-phase Multiway MergeSort Disk
23
Two-phase Multiway MergeSort
Main memory One block per sublist Two-phase Multiway MergeSort Disk
24
Two-phase Multiway MergeSort
Main memory One block per sublist Two-phase Multiway MergeSort Disk
25
Two-phase Multiway MergeSort
Main memory Two-phase Multiway MergeSort Disk
26
Two-phase Multiway MergeSort
disk read/write: 40 ms a tuple: 160 bytes a block: 16KB (100 tuples) a relation R: 1.6 GB (10M tuples, 100K blocks) main memory: 100MB (6400 blocks) Two-phase Multiway MergeSort # sublists = 100K/6400 = 16 thus, in phase 2, we can easily hold a block for each sublist in the main memory Disk block read/write: 100K (blocks) * 4 = 400K disk block read/write = 16M ms = seconds < 4.5 hours
27
Read Chapter 13 for more details on
memory structures
28
Graduate Database DBMS lock table DDL language DDL complier file
administrator DDL complier lock table DDL language file manager logging & recovery concurrency control transaction manager database programmer index/file manager buffer manager query execution engine DML complier main memory buffers DML (query) language secondary storage (disks) DBMS Graduate Database
29
Graduate Database DBMS lock table DDL language DDL complier file
administrator DDL complier lock table DDL language file manager logging & recovery concurrency control transaction manager database programmer index/file manager buffer manager query execution engine DML complier main memory buffers DML (query) language secondary storage (disks) DBMS Graduate Database
30
Graduate Database DBMS lock table DDL language DDL complier file
administrator DDL complier lock table DDL language file manager logging & recovery concurrency control transaction manager database programmer index/file manager buffer manager query execution engine DML complier main memory buffers DML (query) language secondary storage (disks) DBMS Graduate Database
31
What Does DBMS Do?
32
What Does DBMS Do? Execute input database programs;
Manage system efficiency, data consistency, and system/data reliability.
33
What Does DBMS Do? How? Execute input database programs;
Manage system efficiency, data consistency, and system/data reliability. How?
34
What Does DBMS Do? How? Execute input database programs;
Manage system efficiency, data consistency, and system/data reliability. How?
35
What Does DBMS Do? Prepare a collection A of efficient algorithms for operations in relational algebra;
36
What Does DBMS Do? Prepare a collection A of efficient algorithms for operations in relational algebra; For a given database program P:
37
What Does DBMS Do? Prepare a collection A of efficient algorithms for operations in relational algebra; For a given database program P: 1. understand the program P;
38
What Does DBMS Do? Prepare a collection A of efficient algorithms for operations in relational algebra; For a given database program P: 1. understand the program P; 2. translate the program P into an expression E in relational algebra;
39
What Does DBMS Do? Prepare a collection A of efficient algorithms for operations in relational algebra; For a given database program P: 1. understand the program P; 2. translate the program P into an expression E in relational algebra; 3. convert E into an algorithm using algorithms in the collection A;
40
What Does DBMS Do? Prepare a collection A of efficient algorithms for operations in relational algebra; For a given database program P: 1. understand the program P; 2. translate the program P into an expression E in relational algebra; 3. convert E into an algorithm using algorithms in the collection A; take care of issues in optimization, consistency, and security.
41
What Does DBMS Do? Prepare a collection A of efficient algorithms for operations in relational algebra; For a given database program P: 1. understand the program P; 2. translate the program P into an expression E in relational algebra; 3. convert E into an algorithm using algorithms in the collection A; take care of issues in optimization, consistency, and security.
42
Graduate Database DBMS lock table DDL language DDL complier file
administrator DDL complier lock table DDL language file manager logging & recovery concurrency control transaction manager database programmer index/file manager buffer manager query execution engine DML complier main memory buffers DML (query) language secondary storage (disks) DBMS Graduate Database
43
What Does DBMS Do? Prepare a collection A of efficient algorithms for operations in relational algebra; For a given database program P: 1. understand the program P; 2. translate the program P into an expression E in relational algebra; 3. convert E into an algorithm using algorithms in the collection A; 4. take care of issues in optimization and security.
44
What Does DBMS Do? Prepare a collection A of efficient algorithms for operations in relational algebra; For a given database program P: 1. understand the program P; Break the program P into “words” (lexical analysis);
45
WHERE bar = ’Joe’’s Bar’ AND Frequents.drinker = Likes.drinker;
Frequents(drinker, bar) Likes(drinker, beer) Example: SELECT beer FROM Likes, Frequents WHERE bar = ’Joe’’s Bar’ AND Frequents.drinker = Likes.drinker;
46
WHERE bar = ’Joe’’s Bar’ AND Frequents.drinker = Likes.drinker;
Frequents(drinker, bar) Likes(drinker, beer) Example: SELECT beer FROM Likes, Frequents WHERE bar = ’Joe’’s Bar’ AND Frequents.drinker = Likes.drinker;
47
How? Example: SELECT beer FROM Likes, Frequents
Frequents(drinker, bar) Likes(drinker, beer) Example: SELECT beer FROM Likes, Frequents WHERE bar = ’Joe’’s Bar’ AND Frequents.drinker = Likes.drinker; How?
48
How? Example: SELECT beer FROM Likes, Frequents
Frequents(drinker, bar) Likes(drinker, beer) Example: SELECT beer FROM Likes, Frequents WHERE bar = ’Joe’’s Bar’ AND Frequents.drinker = Likes.drinker; How? Using the lexical rules of the programming language
49
lexical rules TinySQL grammar Characters
a-z, 0-9, <, >, =, ., ,, ;, `, ’, (, ), [, ], +, -, *, / Lexical Rules letter ::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r| s | t | u | v | w | x | y | z digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 integer ::= digit+ comp-op ::= < | > | = table-name ::= letter(digit | letter)* attribute-name ::= letter(digit | letter)* column-name ::= [table-name.]attribute-name literal ::= “whatever-except-(`)-and-(’)” Keywords CREATE, TABLE, INT, STR20, DROP, SELECT, DISTINCT, FROM, WHERE, ORDER, BY, DELETE, FROM, INSERT, INTO, VALUES, NULL, OR, AND, NOT, TinySQL grammar lexical rules
50
*: means “zero or more” lexical rules |: means “or”
Characters a-z, 0-9, <, >, =, ., ,, ;, `, ’, (, ), [, ], +, -, *, / Lexical Rules letter ::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r| s | t | u | v | w | x | y | z digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 integer ::= digit+ comp-op ::= < | > | = table-name ::= letter(digit | letter)* attribute-name ::= letter(digit | letter)* column-name ::= [table-name.]attribute-name literal ::= “whatever-except-(`)-and-(’)” Keywords CREATE, TABLE, INT, STR20, DROP, SELECT, DISTINCT, FROM, WHERE, ORDER, BY, DELETE, FROM, INSERT, INTO, VALUES, NULL, OR, AND, NOT, |: means “or” +: means “one or more” *: means “zero or more” [ ]: means “optional” TinySQL grammar lexical rules
51
*: means “zero or more” lexical rules |: means “or”
Characters a-z, 0-9, <, >, =, ., ,, ;, `, ’, (, ), [, ], +, -, *, / Lexical Rules letter ::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r| s | t | u | v | w | x | y | z digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 integer ::= digit+ comp-op ::= < | > | = table-name ::= letter(digit | letter)* attribute-name ::= letter(digit | letter)* column-name ::= [table-name.]attribute-name literal ::= “whatever-except-(`)-and-(’)” Keywords CREATE, TABLE, INT, STR20, DROP, SELECT, DISTINCT, FROM, WHERE, ORDER, BY, DELETE, FROM, INSERT, INTO, VALUES, NULL, OR, AND, NOT, SELECT beer FROM Likes, Frequents WHERE bar = ’Joe’’s Bar’ AND Frequents.drinker = Likes.drinker; |: means “or” +: means “one or more” *: means “zero or more” [ ]: means “optional” TinySQL grammar lexical rules
52
lexical rules TinySQL grammar SELECT beer FROM Likes, Frequents
Characters a-z, 0-9, <, >, =, ., ,, ;, `, ’, (, ), [, ], +, -, *, / Lexical Rules letter ::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r| s | t | u | v | w | x | y | z digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 integer ::= digit+ comp-op ::= < | > | = table-name ::= letter(digit | letter)* attribute-name ::= letter(digit | letter)* column-name ::= [table-name.]attribute-name literal ::= “whatever-except-(`)-and-(’)” Keywords CREATE, TABLE, INT, STR20, DROP, SELECT, DISTINCT, FROM, WHERE, ORDER, BY, DELETE, FROM, INSERT, INTO, VALUES, NULL, OR, AND, NOT, SELECT beer FROM Likes, Frequents WHERE bar = ’Joe’’s Bar’ AND Frequents.drinker = Likes.drinker; SCANNER: read the next char c; if c is not a letter or digit then return c; else if c is a digit call INTEGER else call WORD. TinySQL grammar lexical rules
53
lexical rules TinySQL grammar SELECT beer FROM Likes, Frequents
Characters a-z, 0-9, <, >, =, ., ,, ;, `, ’, (, ), [, ], +, -, *, / Lexical Rules letter ::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r| s | t | u | v | w | x | y | z digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 integer ::= digit+ comp-op ::= < | > | = table-name ::= letter(digit | letter)* attribute-name ::= letter(digit | letter)* column-name ::= [table-name.]attribute-name literal ::= “whatever-except-(`)-and-(’)” Keywords CREATE, TABLE, INT, STR20, DROP, SELECT, DISTINCT, FROM, WHERE, ORDER, BY, DELETE, FROM, INSERT, INTO, VALUES, NULL, OR, AND, NOT, SELECT beer FROM Likes, Frequents WHERE bar = ’Joe’’s Bar’ AND Frequents.drinker = Likes.drinker; SCANNER: read the next char c; if c is not a letter or digit then return c; else if c is a digit call INTEGER else call WORD. WORD: 1. read the next char c; 2. while c is a digit/letter do add c to the output; read the next char c; 3. if c = “.” …… TinySQL grammar lexical rules
54
What Does DBMS Do? Prepare a collection A of efficient algorithms for operations in relational algebra; For a given database program P: 1. understand the program P; Break the program P into “words” (lexical analysis);
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.