Presentation is loading. Please wait.

Presentation is loading. Please wait.

Seminar #3 CM036: Advanced Databases1 Seminar 4: Relational Algebra and its Simulation using SQL Purpose To understand how the relational operations are.

Similar presentations


Presentation on theme: "Seminar #3 CM036: Advanced Databases1 Seminar 4: Relational Algebra and its Simulation using SQL Purpose To understand how the relational operations are."— Presentation transcript:

1 Seminar #3 CM036: Advanced Databases1 Seminar 4: Relational Algebra and its Simulation using SQL Purpose To understand how the relational operations are implemented in SQL To investigate relational databases using queries which can be expressed as algebraic operations To compare the actual output produced by an SQL interpreter from a database with the result of applying operations to its relational model Scenario The Company database contains data about the departments with their employees, as well as for the department projects with the employees working on them. The set of relations in the Company relational schema is provided on the Figure 1. Data for one particular instance of database Company is provided on Figure 2. The SQL script for creating of relational database with the above test data preloaded is provided in the file Company.sql which you can download from Blackboard or from: http://computing.unn.ac.uk/staff/cgma2/cm036/ WeekThree/

2 Seminar #3 CM036: Advanced Databases2 Company Relational Schema DEPT: stores data about company departments, including their managers EMP: stores data about people working in the company PROJ: stores data about the projects on which the company currently works ALLOC: stores data about the people allocated to different projects Figure 1

3 Seminar #3 CM036: Advanced Databases3 Database Schema Instance Figure 2

4 Seminar #3 CM036: Advanced Databases4 Tasks for the Seminar 1. Write the following queries against Company database using both relational algebra operators first and then using SQL i. Get a list of employee numbers ii. Get details of employees with salaries in excess of 15,000 pounds iii. Get a list of departments which have projects or employees iv. Get a list of departments which have both projects and employees v. Get a list of departments that have projects but no employees are working on them vi. Get information on all possible combinations of employees and departments vii. Find information on those employees and their departments who are working for them but are not their managers viii. Find information about employees who are currently working on projects ix. Find information about the projects of the departments x. Part (ix) including registered projects which are not assigned to any department xi. Part (x) including departments without registered projects

5 Seminar #3 CM036: Advanced Databases5 2. Connect to the Oracle database using SQL*Plus, load the Company database contained in the file Company.sql (downloadable from Blackboard) and execute the SQL scripts you have written against it. Connect to the Oracle database using SQL*Plus Load the Company database > @Company Execute the queries Execute your own queries in SQL which implement exactly the same algebra queries as the ones written in the algebra before Compare the results Why the results received as an output of SQL interpreter with the expected results in the case of applying algebraic operations on the relational schema differ (if they really differ)?


Download ppt "Seminar #3 CM036: Advanced Databases1 Seminar 4: Relational Algebra and its Simulation using SQL Purpose To understand how the relational operations are."

Similar presentations


Ads by Google