Week 5 Lab Essay

719 WordsNov 24, 20143 Pages
lab DATABASE SYSTEMS Made By: M Faizan Khan Niazi Session: Fall 2014 Faculty of Information Technology UCP Lahore Pakistan Summary: Relations in relational algebra are seen as sets of tuples, so we can use basic set operations. Review of concepts and operations from set theory * set * element * no duplicate elements (but: multiset = bag) * no order among the elements (but: ordered set) * subset * proper subset (with fewer elements) * superset * union * intersection * set difference * cartesian product Projection Example: The table E (for EMPLOYEE) nr | name | salary | 1 | John | 100 | 5 | Sarah | 300 | 7 | Tom | 100 | SQL | Result | Relational algebra | select salaryfrom E | salary | 100 | 300 | | PROJECTsalary(E) | select nr, salaryfrom E | nr | salary | 1 | 100 | 5 | 300 | 7 | 100 | | PROJECTnr, salary(E) | Note that there are no duplicate rows in the result. Selection The same table E (for EMPLOYEE) as above. SQL | Result | Relational algebra | select *from Ewhere salary < 200 | nr | name | salary | 1 | John | 100 | 7 | Tom | 100 | | SELECTsalary< 200(E) | select *from Ewhere salary < 200and nr >= 7 | nr | name | salary | 7 | Tom | 100 | | SELECTsalary< 200 and nr >= 7(E) | Note that the select operation in relational algebra has nothing to do with the SQL keyword select. Selection in relational algebra returns those tuples in a relation that fulfil a condition, while the SQL keyword select means "here comes an SQL statement". Relational algebra expressions SQL | Result | Relational algebra | select name, salaryfrom Ewhere salary < 200 | name | salary | John | 100 | Tom | 100 | | PROJECTname, salary (SELECTsalary< 200(E)) or, step by step, using an intermediate resultTemp <-

More about Week 5 Lab Essay

Open Document