Download presentation
Presentation is loading. Please wait.
Published byPriscilla Golden Modified over 9 years ago
1
CPSC-608 Database Systems Fall 2015 Instructor: Jianer Chen Office: HRBB 315C Phone: 845-4259 Email: chen@cse.tamu.edu Notes #6
2
secondary storage (disks) database administrator DDL language database programmer DML (query) language DBMS file manager buffer manager main memory buffers index/file manager DML complier DDL complier query execution engine transaction manager concurrency control lock table logging & recovery Graduate Database
3
secondary storage (disks) database administrator DDL language database programmer DML (query) language DBMS file manager buffer manager main memory buffers index/file manager DML complier DDL complier query execution engine transaction manager concurrency control lock table logging & recovery Graduate Database
4
secondary storage (disks) database administrator DDL language database programmer DML (query) language DBMS file manager buffer manager main memory buffers index/file manager DML complier DDL complier query execution engine transaction manager concurrency control lock table logging & recovery Graduate Database
5
What Does DBMS Do?
6
Prepare a collection C of efficient algorithms for operations in relational algebra; What Does DBMS Do?
7
Prepare a collection C of efficient algorithms for operations in relational algebra; For a given database program P: What Does DBMS Do?
8
Prepare a collection C of efficient algorithms for operations in relational algebra; For a given database program P: 1. understand the program P; What Does DBMS Do?
9
Prepare a collection C 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; What Does DBMS Do?
10
Prepare a collection C 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 C; What Does DBMS Do?
11
Prepare a collection C 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 C; 4. take care of issues in optimization and security. What Does DBMS Do?
12
Prepare a collection C 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 C; 4. take care of issues in optimization and security. What Does DBMS Do?
13
secondary storage (disks) database administrator DDL language database programmer DML (query) language DBMS file manager buffer manager main memory buffers index/file manager DML complier DDL complier query execution engine transaction manager concurrency control lock table logging & recovery Graduate Database
14
Suppose that we have relations: Frequents(drinker, bar) and Likes(drinker, beer) How do we “understand” SELECT beer FROM Likes, Frequents WHERE bar = ’Joe’’s Bar’ AND Frequents.drinker = Likes.drinker;
15
DDL Statements CREATE TABLE ( ); CREATE VIEW AS ; CREATE ASSERTION CHECK ( ); CREATE TRIGGER CREATE INDEX ON ( ); DROP TABLE ; ALTER TABLE ADD ; ALTER TABLE DROP ; DML Statements SELECT select-list FROM from-list WHERE conditions GROUP BY group-list HAVING conditions; (subquery) UNION (subquery); (subquery) INTERSECT (subquery); (subquery) EXCEPT (subquery); R CROSS JOIN S; R NATURAL JOIN S; R JOIN S ON ; INSERT INTO VALUES ( ); DELETE FROM WHERE ; UPDATE SET WHERE ;
16
DDL Statements CREATE TABLE ( ); CREATE VIEW AS ; CREATE ASSERTION CHECK ( ); CREATE TRIGGER CREATE INDEX ON ( ); DROP TABLE ; ALTER TABLE ADD ; ALTER TABLE DROP ; DML Statements SELECT select-list FROM from-list WHERE conditions GROUP BY group-list HAVING conditions; (subquery) UNION (subquery); (subquery) INTERSECT (subquery); (subquery) EXCEPT (subquery); R CROSS JOIN S; R NATURAL JOIN S; R JOIN S ON ; INSERT INTO VALUES ( ); DELETE FROM WHERE ; UPDATE SET WHERE ;
17
Symbols 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
18
Syntax Rules statement ::= create-table-statement | drop-table-statement | select-statement | delete-statement | insert-statement create-table-statement ::= CREATE TABLE table-name(attribute-type-list) attribute-type-list ::= attribute-name data-type | attribute-name data-type, attribute-type-list data-type ::= INT | STR20 drop-table-statement ::= DROP TABLE table-name select-statement ::= SELECT [DISTINCT] select-list FROM table-list [WHERE search-condition] [ORDER BY column-name] select-list ::= * | select-sublist select-sublist ::= column-name | column-name, select-sublist table-list ::= table-name | table-name, table-list delete-statement ::= DELETE FROM table-name [WHERE search-condition] insert-statement ::= INSERT INTO table-name(attribute-list) insert-tuples insert-tuples ::= VALUES (value-list) | select-statement attribute-list ::= attribute-name | attribute-name, attribute-list value ::= literal | integer | NULL value-list ::= value | value, value-list search-condition ::= boolean-term | boolean-term OR search-condition boolean-term ::= boolean-factor | boolean-factor AND boolean-term boolean-factor ::= [NOT] boolean-primary boolean-primary ::= comparison-predicate | "[" search-condition "]" comparison-predicate ::= expression comp-op expression expression ::= term | term + expression | term - expression term ::= factor | factor * term | factor / term factor ::= column-name | literal | integer | ( expression ) TinySQL grammar syntax rules
19
Syntax Rules statement ::= create-table-statement | drop-table-statement | select-statement | delete-statement | insert-statement create-table-statement ::= CREATE TABLE table-name(attribute-type-list) attribute-type-list ::= attribute-name data-type | attribute-name data-type, attribute-type-list data-type ::= INT | STR20 drop-table-statement ::= DROP TABLE table-name select-statement ::= SELECT [DISTINCT] select-list FROM table-list [WHERE search-condition] [ORDER BY column-name] select-list ::= * | select-sublist select-sublist ::= column-name | column-name, select-sublist table-list ::= table-name | table-name, table-list delete-statement ::= DELETE FROM table-name [WHERE search-condition] insert-statement ::= INSERT INTO table-name(attribute-list) insert-tuples insert-tuples ::= VALUES (value-list) | select-statement attribute-list ::= attribute-name | attribute-name, attribute-list value ::= literal | integer | NULL value-list ::= value | value, value-list search-condition ::= boolean-term | boolean-term OR search-condition boolean-term ::= boolean-factor | boolean-factor AND boolean-term boolean-factor ::= [NOT] boolean-primary boolean-primary ::= comparison-predicate | "[" search-condition "]" comparison-predicate ::= expression comp-op expression expression ::= term | term + expression | term - expression term ::= factor | factor * term | factor / term factor ::= column-name | literal | integer | ( expression ) TinySQL grammar syntax rules nonterminals
20
Prepare a collection C 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 C; 4. take care of issues in optimization and security. What Does DBMS Do?
21
Prepare a collection C 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 C; 4. take care of issues in optimization and security. What Does DBMS Do? Start with a single node labeled “ ”, repeatedly pick a leaf that is a nonterminal, and give it its children using a syntax rule.
22
SELECT beer FROM Likes, Frequents WHERE bar = ’Joe’’s Bar’ AND Frequents.drinker = Likes.drinker;
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.