230 likes | 432 Views
Implementation of Database System Introduction. Donghui Zhang. Partially using Prof. Hector Garcia-Molina’s slides (Notes01) http://www-db.stanford.edu/~ullman/dscb.html. Relations. Statements. Results. Isn’t Implementing a Database System Simple?. Introducing the. MEGATRON 3000.
E N D
Implementation of Database SystemIntroduction Donghui Zhang Partially using Prof. Hector Garcia-Molina’s slides (Notes01) http://www-db.stanford.edu/~ullman/dscb.html
Relations Statements Results Isn’t Implementing a Database System Simple?
Introducing the MEGATRON 3000 Database Management System • The latest from Megatron Labs • Incorporates latest relational technology • UNIX compatible
Megatron 3000 Implementation Details • Relations stored in files (ASCII) e.g., relation R is in /usr/db/R Smith # 123 # CS Jones # 522 # EE . . .
Megatron 3000 Implementation Details • Directory file (ASCII) in /usr/db/directory R1 # A # INT # B # STR … R2 # C # STR # A # INT … . . .
Megatron 3000Sample Sessions % MEGATRON3000 Welcome to MEGATRON 3000! & & quit % . . .
Megatron 3000Sample Sessions & select * from R # Relation R ABC SMITH 123 CS &
Megatron 3000Sample Sessions & select A,B from R,S where R.A = S.A and S.C > 100 # AB 123 CAR 522 CAT &
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
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
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. • Solution: Indexing!
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!
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!
Other DBMS Issues • Security • API • Interact with other DBMS • GUI
Project Course Overview • Indexing storage, buffer, B+-tree, Hashing • Query optimization query compiler, optimization, execution • Transaction management concurrency control, logging, recovery
DBMS Structure • Simplified version, without transaction management. • This is the version you will implement for the project.
DBMS Structure • Disk storage stores a set of paginated files. • Buffer manager: buffers disk page. • Index manager: manages loaded indices.
DBMS Structure • Execution engine executes queries. • Query parsing • Query optimization • Query processing • Meta data manager supplies meta data to the execution engine.
DBMS Structure • Connection manager creates a server socket, accepts client connections and creates a new thread for each connection.
Project • Two programs: a server and a client. • Java • Multi-threaded programming • Socket network programming • Paginated file access • (simple) GUI.
Client • GUI interface. • Take server name, port number. • Allow the user to connect/disconnect. • Take a (SQL) command. • Allow the user to send the command to server. • Display server response.
Help provided • Multithreaded socket programming page • Two tutorials • Sample code • NEUStore package • PDF description • Disk-based index construction support • HeapFile, LRUBuffer
Summary • Implement database system server. (versus design client application to access a database system) • Indexing, query processing, transaction management. • Project with extensive Java programming.