Formal Relational Query
Formal Relational Query
Operation of RA
The fundamental operations in the relational algebra are select, project, union, set difference, Cartesian product ,and rename. In addition to the fundamental operations, there are several other operationsnamely, set intersection, natural join,and assignment. We shall define these operations in terms of the fundamental operations.
Fundamental Operations
The select, project, and rename operations are called unary operations, because they operate on one relation. The other three operations operate on pairs of relations and are, therefore, called binary operations.
Select Operation
Example
Cartesian Product
Assignment Operation
Dept
DeptName Sales Production Mgr Harriet Charles
George Harriet
Suppose that we want to find out the sum of salaries of all instructors; the relationalalgebra expression for this query is:
RA Example
Find the total number of instructors who teach a course in the Spring 2010 semester.
RA Example
Find the average salary in each department.
RA Example
Find the average salary of all instructors.
Aggregation Operation
Relational Calculus
The Tuple Relational Calculus The Domain Relational Calculus
TRC Example
TRC Example
Find the instructor ID for each instructor with a salary greater than $80,000.
Find the names of all instructors whose department is in the Watson building.
Definition
DRC Example