Copyright © 2011 Ramez Elmasri and Shamkant Navathe Lecture 8 Relational Algebra April 26, 2015.

Slides:



Advertisements
Similar presentations
Chapter 6 The Relational Algebra
Advertisements

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 6 The Relational Algebra.
พีชคณิตแบบสัมพันธ์ (Relational Algebra) บทที่ 3 อ. ดร. ชุรี เตชะวุฒิ CS (204)321 ระบบฐานข้อมูล 1 (Database System I)
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 6 (Continued) The Relational Algebra and Calculus.
The Relational Algebra
Database Systems Chapter 6 ITM Relational Algebra The basic set of operations for the relational model is the relational algebra. –enable the specification.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
Relational Algebra Archana Gupta CS 157. What is Relational Algebra? Relational Algebra is formal description of how relational database operates. It.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Chapter 4 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
The Relational Algebra and Calculus. Relational Algebra Overview Relational algebra is the basic set of operations for the relational model These operations.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 6 The Relational Algebra and Calculus.
Relational Algebra Example Database Application (COMPANY) Relational Algebra –Unary Relational Operations –Relational Algebra Operations From Set Theory.
Relational Algebra - Chapter (7th ed )
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 6 The Relational Algebra and Calculus.
CS 380 Introduction to Database Systems Chapter 7: The Relational Algebra and Relational Calculus.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 6 The Relational Algebra.
CSE314 Database Systems The Relational Algebra and Relational Calculus Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
+ Division Not supported as a primitive operator, but useful for expressing queries like: Find sailors who have reserved all boats. Precondition: in A/B,
METU Department of Computer Eng Ceng 302 Introduction to DBMS The Relational Algebra by Pinar Senkul resources: mostly froom Elmasri, Navathe and other.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
October 9, Announcements Exam Tuesday in class –Closed book Program 2 due Friday –Turn in using D2L dropbox –Only turn in the 4 files specified.
Relational Algebra. 2 Outline  Relational Algebra Unary Relational Operations Relational Algebra Operations from Set Theory Binary Relational Operations.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Chapter 6 The Relational Algebra Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 6 The Relational Algebra.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 6 The Relational Algebra.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 Part a The Relational Algebra and Relational Calculus Hours 1,2.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Al-Maarefa College for Science and Technology INFO 232: Database systems Chapter 3 “part 2” The Relational Algebra and Calculus Instructor Ms. Arwa Binsaleh.
Advanced Relational Algebra & SQL (Part1 )
The Relational Algebra. Slide 6- 2 Outline Relational Algebra Unary Relational Operations Relational Algebra Operations From Set Theory Binary Relational.
Slide 6- 1 Additional Relational Operations Aggregate Functions and Grouping A type of request that cannot be expressed in the basic relational algebra.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
CpSc 462/662: Database Management Systems (DBMS) (TEXNH Approach) Relational Algebra James Wang.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Dr. Mohamed Hegazi1 The Relational Algebra and Relational Calculus.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
Chapter 6 The Relational Algebra Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus تنبيه : شرائح العرض.
Relational Algebra National University of Computer and Emerging Sciences Lecture # 6 June 30,2012.
Chapter 4 The Relational Algebra and Calculus
The Relational Algebra and Calculus
CSE202 Database Management Systems
Database Systems Chapter 6
The Relational Algebra
The Relational Algebra and Relational Calculus
The Relational Algebra and Relational Calculus
Chapter (6) The Relational Algebra and Relational Calculus Objectives
The Relational Algebra and Calculus
Chapter # 6 The Relational Algebra and Calculus
Fundamental of Database Systems
Relational Algebra.
The Relational Algebra and Relational Calculus
Chapter 6: Relational Algebra Fall 2015 Dr. Abdullah Almutairi
Elmasri/Navathe, Fundamentals of Database Systems, 4th Edition
Chapter 4 The Relational Algebra and Calculus
CS4222 Principles of Database System
The Relational Algebra and Calculus
The Relational Algebra and Relational Calculus
The Relational Algebra
The Relational Algebra and The Relational Calculus
Presentation transcript:

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Lecture 8 Relational Algebra April 26, 2015

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Chapter 6 Outline  Unary Relational Operations: SELECT and PROJECT  Relational Algebra Operations from Set Theory  Binary Relational Operations: JOIN and DIVISION  Additional Relational Operations  Examples of Queries in Relational Algebra

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide 6- 4 Relational Algebra Overview  Relational Algebra consists of several groups of operations  Unary Relational Operations SELECT (symbol:  (sigma)) PROJECT (symbol:  (pi)) RENAME (symbol:  (rho))  Relational Algebra Operations From Set Theory UNION (  ), INTERSECTION (  ), DIFFERENCE (or MINUS, – ) CARTESIAN PRODUCT ( x )  Binary Relational Operations JOIN (several variations of JOIN exist) DIVISION  Additional Relational Operations AGGREGATE FUNCTIONS (These compute summary of information: for example, SUM, COUNT, AVG, MIN, MAX)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe 5 Selection Condition  Operators:, =,   Simple selection condition:  operator  AND  OR  NOT  NOTE: Each attribute in condition must be one of the attributes of the relation name

Copyright © 2011 Ramez Elmasri and Shamkant Navathe The Relational Algebra  Relational algebra  Basic set of operations for the relational model  Relational algebra expression  Sequence of relational algebra operations

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Unary Relational Operations: SELECT and PROJECT  The SELECT Operation The Select operator selects tuples that satisfies a predicate  Example: retrieve the employees whose salary is 30,000 б Salary = 30,000 (Employee)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Equivalence from SQL to RA SELECT * FROM R WHERE Equals

Copyright © 2011 Ramez Elmasri and Shamkant Navathe

Unary Relational Operations: SELECT and PROJECT (cont’d.)  Example:  applied independently to each individual tuple t in R  If condition evaluates to TRUE, tuple selected  Boolean conditions AND, OR, and NOT  Unary  Applied to a single relation

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Unary Relational Operations: SELECT and PROJECT (cont’d.)  Selectivity  Fraction of tuples selected by a selection condition  SELECT operation commutative  Cascade SELECT operations into a single operation with AND condition

Copyright © 2011 Ramez Elmasri and Shamkant Navathe 12 Select Operator Produce table containing subset of rows of argument table satisfying condition Example: 1123 John 123 Main stamps 1123 John 123 Main coins 5556 Mary 7 Lake Dr hiking 9876 Bart 5 Pine St stamps 1123 John 123 Main stamps 9876 Bart 5 Pine St stamps Person Id Name Address Hobby

Copyright © 2011 Ramez Elmasri and Shamkant Navathe 13 Select Operator  Id>3000 OR Hobby=‘hiking’ (Person)  Id>3000 AND Id <3999 (Person)  NOT(Hobby=‘hiking’) (Person)  Hobby  ‘hiking’ (Person)  (Id > 3000 AND Id < 3999) OR Hobby  ‘hiking’ (Person) 1123 John 123 Main stamps 1123 John 123 Main coins 5556 Mary 7 Lake Dr hiking 9876 Bart 5 Pine St stamps 1123 John 123 Main stamps 9876 Bart 5 Pine St stamps Person Id Name Address Hobby

Copyright © 2011 Ramez Elmasri and Shamkant Navathe 14 Find all employees with salary more than $40,000.  Salary > (Employee)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe

Select Operator Example NameAgeWeight Harry3480 Sally2864 George2970 Helena54 Peter3480 NameAgeWeight Harry3480 Helena54 Peter3480 Person б Age≥34 (Person) NameAgeWeight Helena54 б Age=Weight (Person)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe The PROJECT Operation  Selects columns from table and discards the other columns:  e.g., name of employees: ∏ name (Employee) e.g., name of employees earning more than 80,000: ∏ name (б Salary>80,000 (Employee))

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Project Operator Example NameAgeSalary Harry3480,000 Sally2890,000 George2970,000 Helena5454,280 Peter3440,000 Name Harry Sally George Helena Peter Employee ∏ name (Employee)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Project Operator Example NameAgeSalary Harry3480,000 Sally2890,000 George2970,000 Helena5454,280 Peter3440,000 Name Sally Employee б Salary>80,000 (Employee) NameAgeSalary Sally2890,000 ∏ name (б Salary>80,000 (Employee))

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Sequences of Operations and the RENAME Operation  In-line expression:  Sequence of operations:  Rename attributes in intermediate results  RENAME operation

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Rename Operator  In relational algebra, a rename is a unary operation written as ρ a / b (R) where: a and b are attribute names R is a relation  The result is identical to R except that the b field in all tuples is renamed to an a field.  Example, rename operator changes the name of its input table to its subscript,  ρ employee (Emp)  Changes the name of Emp table to employee

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Rename Operator Example NameSalary Harry80,000 Sally90,000 George70,000 Helena54,280 Peter40,000 Employee ρ EmployeeName / Name (Employee) EmployeeNameSalary Harry80,000 Sally90,000 George70,000 Helena54,280 Peter40,000

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Relational Algebra Operations from Set Theory  UNION, INTERSECTION, and MINUS  Merge the elements of two sets in various ways  Binary operations  Relations must have the same type of tuples

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Union Operator  The union operation is denoted U as in set theory. It returns the union (set union) of two compatible relations.  For a union operation r U s to be legal, we require that, r and s must have the same number of attributes. The domains of the corresponding attributes must be the same.  As in all set operations, duplicates are eliminated.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Union Operator Example FNLN SusanYao RameshShah BarbaraJones AmyFord JimmyWang FNLN JohnSmith RicardoBrown SusanYao FrancisJohnson RameshShah Student Professor FNLN SusanYao RameshShah BarbaraJones AmyFord JimmyWang JohnSmith RicardoBrown FrancisJohnson Student U Professor

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Intersection Operator  Denoted as . For relations R and S, intersection is R  S.  Defines a relation consisting of the set of all tuples that are in both R and S.  R and S must be union-compatible.  Expressed using basic operations: R  S = R – (R – S)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Intersection Operator Example FNLN SusanYao RameshShah BarbaraJones AmyFord JimmyWang FNLN JohnSmith RicardoBrown SusanYao FrancisJohnson RameshShah Student Professor FNLN SusanYao RameshShah Student  Professor

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Set Difference Operator  For relations R and S, Set difference R - S, defines a relation consisting of the tuples that are in relation R, but not in S. Set difference S – R, defines a relation consisting of the tuples that are in relation S, but not in R.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Set Difference Operator Example FNLN SusanYao RameshShah BarbaraJones AmyFord JimmyWang FNLN JohnSmith RicardoBrown SusanYao FrancisJohnson RameshShah Student Professor FNLN BarbaraJones AmyFord JimmyWang Student - Professor FNLN JohnSmith RicardoBrown FrancisJohnson Professor - Student

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Division Operator  The division operator takes as input two relations, called the dividend relation (r on scheme R) and the divisor relation (s on scheme S) such that all the attributes in S also appear in R and S is not empty.  The output of the division operation is a relation on scheme R with all the attributes common with S.  Denoted by ÷  Example: retrieve the names of employees who work on all the projects that ‘John Smith’ works on  Apply to relations R(Z) ÷ S(X)  Attributes of R are a subset of the attributes of S

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Division Operator Example StudentTask FredDatabase1 FredDatabase2 FredCompiler1 EugeneDatabase1 SaraDatabase1 SaraDatabase2 EugeneCompiler1 Task Database1 Database2 Completed DBProject Student Fred Sara Completed / DBProject

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Examples of Division A/B A B1 B2 B3 A/B1A/B2A/B3

Copyright © 2011 Ramez Elmasri and Shamkant Navathe The CARTESIAN PRODUCT (CROSS PRODUCT) Operation  CARTESIAN PRODUCT  CROSS PRODUCT or CROSS JOIN  Denoted by ×  Binary set operation  Relations do not have to be union compatible  Useful when followed by a selection that matches values of attributes

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Binary Relational Operations: JOIN and DIVISION  The JOIN Operation  Denoted by  Combine related tuples from two relations into single “longer” tuples  General join condition of the form AND AND...AND  Example:

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Binary Relational Operations: JOIN  JOIN Operation (denoted by )  The sequence of CARTESIAN PRODECT followed by SELECT is used quite commonly to identify and select related tuples from two relations  A special operation, called JOIN combines this sequence into a single operation  This operation is very important for any relational database with more than a single relation, because it allows us combine related tuples from various relations  The general form of a join operation on two relations R(A1, A2,..., An) and S(B1, B2,..., Bm) is: R S  where R and S can be any relations that result from general relational algebra expressions.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Binary Relational Operations: JOIN (cont.)  Example: Suppose that we want to retrieve the name of the manager of each department.  To get the manager’s name, we need to combine each DEPARTMENT tuple with the EMPLOYEE tuple whose SSN value matches the MGRSSN value in the department tuple.  We do this by using the join operation.  DEPT_MGR  DEPARTMENT MGRSSN=SSN EMPLOYEE  MGRSSN=SSN is the join condition  Combines each department record with the employee who manages the department  The join condition can also be specified as DEPARTMENT.MGRSSN= EMPLOYEE.SSN

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Example of applying the JOIN operation DEPT_MGR  DEPARTMENT MGRSSN=SSN EMPLOYEE

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Some properties of JOIN  Consider the following JOIN operation:  R(A1, A2,..., An) S(B1, B2,..., Bm) R.Ai=S.Bj  Result is a relation Q with degree n + m attributes: Q(A1, A2,..., An, B1, B2,..., Bm), in that order.  The resulting relation state has one tuple for each combination of tuples—r from R and s from S, but only if they satisfy the join condition r[Ai]=s[Bj]  Hence, if R has n R tuples, and S has n S tuples, then the join result will generally have less than n R * n S tuples.  Only related tuples (based on the join condition) will appear in the result

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Binary Relational Operations: EQUIJOIN  EQUIJOIN Operation  The most common use of join involves join conditions with equality comparisons only  Such a join, where the only comparison operator used is =, is called an EQUIJOIN.  In the result of an EQUIJOIN we always have one or more pairs of attributes (whose names need not be identical) that have identical values in every tuple.  The JOIN seen in the previous example was an EQUIJOIN.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe

EQUIJOIN & Natural JOIN  EQUIJOIN  Only = comparison operator used  Always have one or more pairs of attributes that have identical values in every tuple  NATURAL JOIN  Denoted by *  Removes second (superfluous) attribute in an EQUIJOIN condition

Copyright © 2011 Ramez Elmasri and Shamkant Navathe

Natural Join Example NameEmpIDDeptName Harry3415Finance Sally2241Sales George3401Finance Harriet2202Sales DeptNameMgr FinanceGeorge SalesHarriet ProductionCharles Employee Dept NameEmpIDDeptNameMgr Harry3415FinanceGeorge Sally2241SalesHarriet George3401FinanceGeorge Harriet2202SalesHarriet Employee lXl Dept For an example, consider the tables Employee and Dept and their natural join:

Copyright © 2011 Ramez Elmasri and Shamkant Navathe A Complete Set of Relational Algebra Operations  Set of relational algebra operations {σ, π, ∪, ρ, –, ×} is a complete set  Any relational algebra operation can be expressed as a sequence of operations from this set

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Binary Relational Operations: DIVISION  DIVISION Operation  The division operation is applied to two relations  R(Z)  S(X), where X subset Z. Let Y = Z - X (and hence Z = X  Y); that is, let Y be the set of attributes of R that are not attributes of S.  The result of DIVISION is a relation T(Y) that includes a tuple t if tuples t R appear in R with t R [Y] = t, and with t R [X] = t s for every tuple t s in S.  For a tuple t to appear in the result T of the DIVISION, the values in t must appear in R in combination with every tuple in S.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Example of DIVISION

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Additional Relational Operations: Aggregate Functions and Grouping  A type of request that cannot be expressed in the basic relational algebra is to specify mathematical aggregate functions on collections of values from the database.  Examples of such functions include retrieving the average or total salary of all employees or the total number of employee tuples.  These functions are used in simple statistical queries that summarize information from the database tuples.  Common functions applied to collections of numeric values include  SUM, AVERAGE, MAXIMUM, and MINIMUM.  The COUNT function is used for counting tuples or values.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Aggregate Function Operation  Use of the Aggregate Functional operation ℱ  ℱ MAX Salary (EMPLOYEE) retrieves the maximum salary value from the EMPLOYEE relation  ℱ MIN Salary (EMPLOYEE) retrieves the minimum Salary value from the EMPLOYEE relation  ℱ SUM Salary (EMPLOYEE) retrieves the sum of the Salary from the EMPLOYEE relation  ℱ COUNT SSN, AVERAGE Salary (EMPLOYEE) computes the count (number) of employees and their average salary Note: count just counts the number of rows, without removing duplicates

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Using Grouping with Aggregation  The previous examples all summarized one or more attributes for a set of tuples  Maximum Salary or Count (number of) Ssn  Grouping can be combined with Aggregate Functions  Example: For each department, retrieve the DNO, COUNT SSN, and AVERAGE SALARY  A variation of aggregate operation ℱ allows this:  Grouping attribute placed to left of symbol  Aggregate functions to right of symbol  DNO ℱ COUNT SSN, AVERAGE Salary (EMPLOYEE)  Above operation groups employees by DNO (department number) and computes the count of employees and average salary per department

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Examples of applying aggregate functions and grouping

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Additional Relational Operations (cont.)  Recursive Closure Operations  Another type of operation that, in general, cannot be specified in the basic original relational algebra is recursive closure. This operation is applied to a recursive relationship.  An example of a recursive operation is to retrieve all SUPERVISEES of an EMPLOYEE e at all levels — that is, all EMPLOYEE e’ directly supervised by e; all employees e’’ directly supervised by each employee e’; all employees e’’’ directly supervised by each employee e’’; and so on.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Recursive Closure Operations  Operation applied to a recursive relationship between tuples of same type

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Additional Relational Operations (cont.)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Database State for COMPANY  All examples discussed below refer to the COMPANY database shown here.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Notation for Query Trees  Query tree  Represents the input relations of query as leaf nodes of the tree  Represents the relational algebra operations as internal nodes

Copyright © 2011 Ramez Elmasri and Shamkant Navathe

Slide Examples of Queries in Relational Algebra : Procedural Form Q1: Retrieve the name and address of all employees who work for the ‘Research’ department. RESEARCH_DEPT   DNAME=’Research’ (DEPARTMENT) RESEARCH_EMPS  (RESEARCH_DEPT DNUMBER= DNOEMPLOYEE EMPLOYEE) RESULT   FNAME, LNAME, ADDRESS (RESEARCH_EMPS)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide Q2: Retrieve the names of employees who have no dependents. ALL_EMPS   SSN (EMPLOYEE) EMPS_WITH_DEPS ( SSN )   ESSN ( DEPENDENT ) EMPS_WITHOUT_DEPS  (ALL_EMPS - EMPS_WITH_DEPS) RESULT   LNAME, FNAME (EMPS_WITHOUT_DEPS * EMPLOYEE)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide 6- 60

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Slide 6- 61

Copyright © 2011 Ramez Elmasri and Shamkant Navathe

Operations of Relational Algebra

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Operations of Relational Algebra (cont’d.)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Summary  The relational model has rigorously defined query languages that are simple and powerful.  Relational algebra is more operational; useful as internal representation for query evaluation plans.  Several ways of expressing a given query; a query optimizer should choose the most efficient version.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Summary  Formal languages for relational model of data:  Relational algebra: operations, unary and binary operators  Some queries cannot be stated with basic relational algebra operations But are important for practical use