CMSC 127 3rd Long Exam.pdf
Document Details
Uploaded by OticPrudence9241
Tags
Full Transcript
Filters the attributes/columns of a resulting relation R based on the attributes RELATIONAL ALGEBRA listed...
Filters the attributes/columns of a resulting relation R based on the attributes RELATIONAL ALGEBRA listed “select” clause Not (entirely) commutative Procedural language Relations are the inputs - not correct to begin with Resulting relations are the outputs Represent a query in a “mathematical” way - not commutative but proper use of projection Example: OPERATIONS IN RELATIONAL ALGEBRA 1. Show all first and last names of employees. πfirstname, lastname(employee) ○ resulting relation has more or less number of attributes Select operation from the original relation and with the original number of σcondition(relation) tuples where: 2. Show all last names, department numbers, monthly salaries of employees - σ: select symbol πlastname, department, salary(employee) - condition: condition based on attribute(s) relation is the relation to be used Note: You can combine selection and projection (which normally happens) Filters the tuples of a resulting relation R based on the condition provided “where” clause commutative Example: Show the last names and department numbers of employees whose monthly salary is greater than Php 30,000. Rename operation Example: 1. Show all employees who belongs to department number 5. ⍴new_relation(new_attributes)(old_relation) σdepartment=5(employee) where: ○ resulting relation has the same number of attributes from ⍴: select symbol the original relation but with more or less tuples (rows) new_relation(new_attributes): new relation/ attributes 2. Show all employees whose monthly salary is above Php30,000 and belongs old_relation: relation to be used to department 3, 4, and 5. σsalary > 30000 and department >=3 and department