Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Database Systems

Similar presentations


Presentation on theme: "Introduction to Database Systems"— Presentation transcript:

1 Introduction to Database Systems
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems Chapter 6: The Relational Algebra and Relational Calculus

2 Outline Introduction Relational Algebra Unary Relational Operations
Relational Algebra Operations from Set Theory Binary Relational Operations Additional relational Operations Examples of Queries in Relational Algebra Relational Calculus Introduction to Tuple Relational Calculus Introduction to Domain Relational Calculus Chapter 6: The Relational Algebra and Relational Calculus 1

3 Introduction A data model must include a set of operations to manipulate relations and produce new relations as answers to queries. Formal languages for the relational model: Relational algebra: specifies a sequence of operations to specify a query. Relational calculus: specifies the result of a query. (without specifying how to produce the query result) Tuple calculus. Domain Calculus. Chapter 6: The Relational Algebra and Relational Calculus 2

4 Example Chapter 6: The Relational Algebra and Relational Calculus 3

5 Relational Algebra The basic set of operations for the relational model is known as the relational algebra. These operations enable a user to specify basic retrieval requests. The result of a retrieval is a new relation, which may have been formed from one or more relations. A sequence of relational algebra operations forms a relational algebra expression. Chapter 6: The Relational Algebra and Relational Calculus 4

6 Relational Algebra Two basic sets of operations:
Relational operators (specific for relational databases): Select. Project. Join. Division. Set Theoretic Operators: Union. Intersection. Minus. Cartesian product. Chapter 6: The Relational Algebra and Relational Calculus 5

7 Basic Relational Algebra Operations
Select Project Union Intersection Difference R S R S R S Cartesian Product * Chapter 6: The Relational Algebra and Relational Calculus 6

8 Unary Relational Operations - SELECT
Selects a subset of the tuples from a relation that satisfy a selection condition. Syntax:  <selection condition> (<relation name>) Examples: Select the EMPLOYEE tuples whose department is 4.  DNO=4 (EMPLOYEE) Select the tuples for all employees who either work in department 4 and make over $25,000 per year, or work in department 5 and make over $30,000.  (DNO=4 AND SALARY>25000) OR (DNO=5 AND SALARY>30000) (EMPLOYEE) Chapter 6: The Relational Algebra and Relational Calculus 7

9 Unary Relational Operations - SELECT
 (DNO=4 AND SALARY>25000) OR (DNO=5 AND SALARY>30000) (EMPLOYEE) Chapter 6: The Relational Algebra and Relational Calculus 8

10 Unary Relational Operations - SELECT
The SELECT operation  <selection condition> (R) produces a relation S that has the same schema as R The select operation is commutative:  <condition1> ( <condition2> (R)) =  <condition2> ( <condition1> (R)) A cascaded SELECT operation may be replaced by a single selection with a conjunction of all the conditions:  <condition1> ( <condition2> ( <condition3> (R))) =  <condition1> AND <condition2> AND <condition3> (R) Chapter 6: The Relational Algebra and Relational Calculus 9

11 Unary Relational Operations - PROJECT
Selects certain columns from the table and discards the other columns. Syntax: p <attribute list> (<relation name>) Example: list each employee’s first and last name and salary. p LNAME, FNAME, SALARY (EMPLOYEE) The project operation removes any duplicate tuples, so the result of the project operation is a set of tuples and hence a valid relation. Chapter 6: The Relational Algebra and Relational Calculus 10

12 Unary Relational Operations - PROJECT
p LNAME, FNAME, SALARY (EMPLOYEE) Chapter 6: The Relational Algebra and Relational Calculus 11

13 Sequence of Operations & RENAME Operation
We can: Nest the relational algebra operations as a single expression, or Apply one operation at a time and create intermediate result relations, and give it a name. Example: retrieve the first name, last name, and salary of all employees who work in department number 5. p FNAME, LNAME, SALARY ( DNO=5 (EMPLOYEE)) or TEMP  DNO=5 (EMPLOYEE) R p FNAME, LNAME, SALARY (TEMP) The rename operator is r. Chapter 6: The Relational Algebra and Relational Calculus 12

14 Sequence of Operations & RENAME Operation
p FNAME, LNAME, SALARY ( DNO=5 (EMPLOYEE)) TEMP  DNO=5 (EMPLOYEE) R(FIRSTNAME,LASTNAME,SALARY) p FNAME, LNAME, SALARY (TEMP) Chapter 6: The Relational Algebra and Relational Calculus 13

15 Relational Algebra Operations From Set Theory
UNION, INTERSECTION, & MINUS Operands need to be union compatible for the result to be a valid relation. In practice, it is rare that two relations are union compatible (occurs most often in derived relations). Chapter 6: The Relational Algebra and Relational Calculus 14

16 Relational Algebra Operations From Set Theory - UNION
The result of this operation, denoted by R  S, is a relation that includes all tuples that are either in R or in S or in both R and S. Duplicate tuples are eliminated. Chapter 6: The Relational Algebra and Relational Calculus 15

17 Relational Algebra Operations From Set Theory - UNION
Example: retrieve the SSN of all employees who either work in department 5 or directly supervise an employee who works in department 5. DEP5_EMPS  DNO=5 (EMPLOYEE) RESULT p SSN (DEP5_EMPS) RESULT2(SSN) p SUPERSSN (DEP5_EMPS) RESULT RESULT1  RESULT2 Chapter 6: The Relational Algebra and Relational Calculus 16

18 Relational Algebra Operations From Set Theory - INTERSECTION
The result of this operation, denoted by R S, is a relation that includes all tuples that are in both R and S. Chapter 6: The Relational Algebra and Relational Calculus 17

19 Relational Algebra Operations From Set Theory - MINUS
The result of this operation, denoted by R - S, is a relation that includes all tuples that are in R but not in S. Chapter 6: The Relational Algebra and Relational Calculus 18

20 The Set Operations b. STUDENT  INSTRUCTOR c. STUDENT INSTRUCTOR
d. STUDENT - INSTRUCTOR e. INSTRUCTOR - STUDENT Chapter 6: The Relational Algebra and Relational Calculus 19

21 Relational Algebra Operations From Set Theory
CARTESIAN PRODUCT This operation is used to combine tuples from two relations in a combinational fashion. The result denoted by R1 x R2 is a relation that includes all the possible combinations of tuples from R1 and R2. It is not a very useful operation by itself but it is used in conjunction with other operations. Chapter 6: The Relational Algebra and Relational Calculus 20

22 Relational Algebra Operations From Set Theory
CARTESIAN PRODUCT Example: retrieve a list of names of each female employee’s dependents. FEMALE_EMPS  SEX=‘F’ (EMPLOYEE) EMPNAMES p FNAME, LNAME, SSN (FEMALE _EMPS) EMP_DEPENDENTS EMPNAMES x DEPENDENT ACTUAL_DEPENDENTS  SSN=ESSN (EMP_DEPENDENTS) RESULT p FNAME, LNAME, DEPENTDENT_NAME (ACTUAL_DEPENDENTS) Chapter 6: The Relational Algebra and Relational Calculus 21

23 Relational Algebra Operations From Set Theory
CARTESIAN PRODUCT Chapter 6: The Relational Algebra and Relational Calculus 22

24 Completeness of Relational Algebra
SELECT, PROJECT, UNION, MINUS, and CARTESIAN PRODUCT are the basic operators of the relational algebra. Additional operators are defined as combination of two or more of the basic operations. Example: JOIN = CARTESIAN PRODUCT + SELECT. DIVISION = PROJECT + CARTESIAN PRODUCT + MINUS. Chapter 6: The Relational Algebra and Relational Calculus 23

25 Binary Relational Operations - JOIN
The JOIN operation is used to combine related tuples from two relations into single tuples. Syntax: R <join condition> S (does not require union compatibility of R and S). Example: retrieve the name of the manager of each department. DEPT_MGR DEPARTMENT MGRSSN=SSN EMPLOYEE RESULT p DNAME, LNAME, FNAME (DEPT_MGR) Chapter 6: The Relational Algebra and Relational Calculus 24

26 Binary Relational Operations - EQUIJOIN
Joins conditions with equality comparisons only. In the result of an EQUIJOIN, one or more pairs of attributes always have identical values in every tuple. e.g. The value of Mgr_ssn and Ssn are identical in every tuple of DEPT_MGR because of the equality join condition specified on these two attributes. Chapter 6: The Relational Algebra and Relational Calculus 25

27 Binary Relational Operations - NATURAL JOIN
Because one of each pair of attributes with identical values is superfluous, a new operation called NATUARAL JOIN was created to get rid of the second (superfluous) attribute in an EQUIJOIN condition. The standard definition requires that the two join attributes, or each pair of corresponding join attributes, have the same name in both relations. Syntax: R * S Chapter 6: The Relational Algebra and Relational Calculus 26

28 Binary Relational Operations - NATURAL JOIN
To apply a NATURAL JOIN on the DNUMBER attribute of DEPARTMENT and DEPT_LOCATIONS, it is sufficient to write: DEPT_LOCS DEPARTMENT * DEPT_LOCATIONS Chapter 6: The Relational Algebra and Relational Calculus 27

29 Binary Relational Operations - NATURAL JOIN
To apply a NATURAL JOIN on the department number attribute of DEPARTMENT and PROJECT: DEPT r (DNAME,DNUM,MGRSSN,MGRSTARTDATE) (DEPARTMENT) PROJ_DEPT PROJECT * DEPT Chapter 6: The Relational Algebra and Relational Calculus 28

30 Binary Relational Operations - DIVISION
The division operation is applied to two relations R(Z) S(X), where X is a subset from Z. Example: retrieve the names of employees who work on all the projects that ‘John Smith’ works on. SMITH  FNAME=‘John’ AND LNAME=‘Smith’ (EMPLOYEE) SMITH_PNOS p PNO (WORKS_ON ESSN=SSN SMITH) SSN_PNOS p ESSN, PNO (WORKS_ON) SSNS(SSN) SSN_PNOS SMITH_PNOS RESULT p FNAME, LNAME (SSNS * EMPLOYEE) . . Chapter 6: The Relational Algebra and Relational Calculus 29

31 Binary Relational Operations - DIVISION
Chapter 6: The Relational Algebra and Relational Calculus 30

32 Notation for Query Tree
πP.Pnumber,P.Dnum,E.Lname,E.Adress,E.BDate 3 D.Mgr_ssn=E.Ssn 2 EMPLOYEE E P.Dnum=D.Dnumber D 1 DEPARTMENT σ P.Plocation=‘Stafford P PROJECT

33 Additional Relational Operations
Generalized Projection The generalized projection operation extends the projection operation by allowing functions of attributes to be included in the projection list. The generalized form is expressed as Π F1,F2,..Fn(R) Where F1, F2...Fn are functions over the attributes in relation R and may involve constants. Chapter 6: The Relational Algebra and Relational Calculus 31

34 Additional Relational Operations
Generalized Projection Consider the relation EMPLOYEE (Ssn,Salary, Deduction, Years_service) A report may be required to show Net Salary = Salry-Deduction Bonus = 2000 * Years_service Tax = 0.25 * Salary Then a generalized projection combined with renaming is used as REPORT ← ρ(Ssn,Net_salary, Bonus, Tax) (πSsn,Salary-Deduction, 2000 * Years_service, 0.25 * Salary(EMPLOYEE)) Chapter 6: The Relational Algebra and Relational Calculus 31

35 Additional Relational Operations
Generalized Projection Consider the relation EMPLOYEE (Ssn,Salary, Deduction, Years_service) A report may be required to show Net Salary = Salry-Deduction Bonus = 2000 * Years_service Tax = 0.25 * Salary Then a generalized projection combined with renaming is used as REPORT ← ρ(Ssn,Net_salary, Bonus, Tax) (πSsn,Salary-Deduction, 2000 * Years_service, 0.25 * Salary(EMPLOYEE)) Chapter 6: The Relational Algebra and Relational Calculus 31

36 Additional Relational Operations
Aggregate Functions and Grouping The first type of request that cannot be expressed in the basic relational algebra is to specify mathematical aggregate functions on collection of values from the database. Common functions applied to collections of numeric values include: SUM. AVERAGE. MAXIMUM. MINIMUM. The COUNT function is used for counting tuples or values. Chapter 6: The Relational Algebra and Relational Calculus 31

37 Additional Relational Operations
Aggregate Functions and Grouping Another common type of request involves grouping the tuples in a relation by the value of some of their attributes and then applying an aggregate function independently to each group. Syntax: <grouping attributes> <function list> (R) Example: COUNT SSN , AVERAGE SALARY (EMPLOYEE) Chapter 6: The Relational Algebra and Relational Calculus 32

38 Additional Relational Operations
Aggregate Functions and Grouping Example: DNO COUNT SSN , AVERAGE SALARY (EMPLOYEE) Example: r R (DNO, NO_OF_EMPLOYEES, AVERAGE_SAL) (DNO COUNT SSN , AVERAGE SALARY (EMPLOYEE)) Chapter 6: The Relational Algebra and Relational Calculus 33

39 Additional Relational Operations
Recursive Closure Operations A type of request that cannot be specified in the basic original relational algebra. This operation is applied to a recursive relationship. e.g. The relationship between Ssn and Super_ssn of the EMPLOYEE relation. It relates the employee tuple (in the role of supervisee) to another employee tuples (in the role of supervisor) An example of a recursive operation is to retrieve all supervisees of an employee e at all levels i.e. all employee e’ directly supervised by e, all employee e’’ directly supervised by each employee e’; all employees e’’’ directly supervised by each employee e’’ and so on. Chapter 6: The Relational Algebra and Relational Calculus 34

40 Additional Relational Operations
Recursive Closure Operations BORG_SSN ← πSsn(σFname=‘James’ AND Lname=‘Borg’(EMPLOYEE)) SUPERVISION(Ssn1,Ssn2)← πSsn, Super_Ssn(EMPLOYEE) RESULT1(SSN) ← πSsn1(SUPERVISION) SSN2=Ssn BORG_SSN) To retriev all employees supervised by Borg at level 2- that is all employees e’’ supervised by some employee e’ who is directly supervised by Borg, we can apply another JOIN to the result of the first query. RESULT2(Ssn) ←πSsn1(SUPERVISION Ssn2=Ssn RESULT1) To get both the set of employees supervised at level 1and 2 by ‘James Borg’, we can apply the UNION operation to the two results, as follows RESULT ← RESULT1 U RESULT2 Chapter 6: The Relational Algebra and Relational Calculus 34

41 SUPERVISION RESULT1 RESULT RESULT2 Borg’s Ssn is 888665555 Ssn
Super_ssn Ssn1 Ssn2 NULL Ssn RESULT Ssn RESULT2 Ssn Borg’s Ssn is

42 Additional Relational Operations
OUTER JOIN Operations In NATUARAL JOIN, the following tuples are eliminated from the join result: Tuples without a matching (or related) tuple. Tuples with null in the join attributes. A set of operations, called OUTER JOINs, can be used when we want to keep all the tuples: in R, or in S, or in both relations in the result of the join. Chapter 6: The Relational Algebra and Relational Calculus 35

43 Additional Relational Operations
OUTER JOIN Operations The left outer join operation ( R S) keeps every tuple in R, if no matching tuple is found in S, then the attributes of S in the join result are filled with null values. The right outer join operation ( R S) keeps every tuple in S, if no matching tuple is found in R, then the attributes of R in the join The full outer join operation (R S) keeps all tuples in both the left and the right relations when no matching tuples are found, padding them with null values as needed. Chapter 6: The Relational Algebra and Relational Calculus 36

44 Additional Relational Operations
OUTER JOIN Operations Example: List all the Employee names and also the name of the departments they manage. Using LEFT OUTER JOIN TEMP ← (EMPLOYEE Ssn=Mgr_ssn DEPARTMENT) RESULT ← πFname,Minit,Lname,Dname(TEMP) The department no. of the employees who do not manage the department will have NULL values. Chapter 6: The Relational Algebra and Relational Calculus 36

45 Additional Relational Operations
OUTER UNION Operation The outer union operation was developed to take the union of tuples from two relations if the relations are not union compatible. The operation will take the UNION of tuples in two relations R(X,Y) and S(X,Z) that are partially compatible meaning that only some of their attributes say X are union compatible. The attributes that are union compatible are represented only once in the result and those attributes that are not union compatible from either relation are also kept in the result relation T(X,Y,Z). Chapter 6: The Relational Algebra and Relational Calculus 37

46 Additional Relational Operations
OUTER UNION Operation e.g. STUDENT(Name, Ssn, Department, Advisor) INSTRUCTOR(Name, Ssn, Department, Rank) STUDENT_OR_INSTRUCTOR(Name, Ssn, Department, Advisor, Rank) All the tuples from both the relations are included in the result, but tuples (Name, Ssn, Department) combination will appear only once in the result. Tuples appearing only in STUDENT will have a NULL for the Rank attribute. whereas tuples appearing only in INSTRUCTOR will have a NULL for the Advisor attribute. A tuple that exists on both relations such as a student who is also an instructor will have values for all its attributes. Chapter 6: The Relational Algebra and Relational Calculus 37

47 Examples of Queries in Relational Algebra
Query 1: Retrieve the name and address of all employees who work for the ‘Research’ department. R_DEPT  DNAME=‘Research’ (DEPARTMENT) R_EMPS (R_DEPT DNUMBER=DNO EMPLOYEE) RESULT p LNAME, FNAME, ADDRESS (R_EMPS) Chapter 6: The Relational Algebra and Relational Calculus 38

48 Examples of Queries in Relational Algebra
Query 2: For every project located in ‘Stafford’, list the project number, the controlling department, and the department manager’s last name, address, and birth date. S_PROJS  PLOCATION=‘Stafford’ (PROJECT) C_DEPT (S_PROJS DNUM=DNUMBER DEPARTMENT) P_DEPT_MGR (C_DEPT MGRSSN=SSN EMPLOYEE) RESULT p PNUMBER, DNUM, LNAME, ADDRESS, BDATE (P_DEPT_MGR) Chapter 6: The Relational Algebra and Relational Calculus 39

49 Examples of Queries in Relational Algebra
Query 3: Find the names of employees who work on all projects controlled by the department number 5. D_5_PROJS(PNO) p PNUMBER ( DNUM=5 (PROJECT)) EMP_PROJ(SSN, PNO) p ESSN, PNO (WORKS_ON) RESULT_EMP_SSNS EMP_PROJ D_5_PROJS RESULT p LNAME, FNAME (RESULT_EMP_SSNS * EMPLOYEE) . Chapter 6: The Relational Algebra and Relational Calculus 40

50 Examples of Queries in Relational Algebra
Query 4: Make a list of project numbers for projects that involve an employee whose last name is ‘Smith’, either as a worker or as a manager of the department that controls the project. SMITHS(ESSN) p SSN ( LNAME=‘Smith’ (EMPLOYEE)) SMITH_W_PROJ p PNO (WORKS_ON * SMITHS) MGRS p LNAME, DNUMBER (EMPLOYEE SSN=MGRSSN DEPARTMENT) SMITH_M_DEPTS(DNUM) p DNUMBER ( LNAME=‘Smith’ (MGRS)) SMITH_M_PROJS(PNO) p PNUMBER (SMITH_M_DEPTS * PROJECT) RESULT (SMITH_W_PROJS  SMITH_M_PROJS) Chapter 6: The Relational Algebra and Relational Calculus 41

51 Examples of Queries in Relational Algebra
Query 5: list the names of all employees with two or more dependents. T1(SSN, NO_OF_DEPTS) ESSN COUNT DEPENDENT_NAME (DEPENDENT) T  NO_OF_DEPS>1 (T1) RESULT p LNAME, FNAME (T2 * EMPLOYEE) Chapter 6: The Relational Algebra and Relational Calculus 42

52 Examples of Queries in Relational Algebra
Query 6: Retrieve the names of employees who have no dependents. ALL_EMPS p SSN (EMPLOYEE) EMPS_WITH_DEPS(SSN) p ESSN (DEPENDENT) EMPS_WITHOUT_DEPS (ALL_EMP - EMP_WITH_DEPS) RESULT p LNAME, FNAME (EMPS_WITHOUT_DEPS * EMPLOYEE) Chapter 6: The Relational Algebra and Relational Calculus 43

53 Examples of Queries in Relational Algebra
Query 7: list the names of managers who have at least one dependent.. MGRS(SSN) p MGRSSN (DEPARTMENT) EMPS_WITH_DEPS(SSN) p ESSN (DEPENDENT) MGRS_WITH_DEPS (MGRS EMPS_WITH_DEPS) RESULT p LNAME, FNAME (MGRS_WITH_DEPS * EMPLOYEE) Chapter 6: The Relational Algebra and Relational Calculus 44

54 The Relational Calculus
A relational calculus expression creates a new relation, which is specified in terms of variables that range: Over rows of stored database relations (in tuple calculus), or Over columns of the stored relations (in domain calculus). In a calculus expression, there is no order of operations to specify how to retrieve the query result. A calculus expression specifies only what information the result should contain. Chapter 6: The Relational Algebra and Relational Calculus 45

55 Introduction to Tuple Relational Calculus
Is based on specifying a number of tuple variables, each tuple variable usually ranges over a particular database relation. A simple tuple relational calculus query is of the form: {t | COND(t)} Example: find all employees whose salary is above $50,000. {t | EMPLOYEE(t) AND t.SALARY>50000} Example: find the first and last names of all employees whose salary is above $50,000. {t.LNAME, t.FNAME | EMPLOYEE(t) AND t.SALARY>50000} Chapter 6: The Relational Algebra and Relational Calculus 46

56 The Existential and Universal Quantifiers
Two special symbols called quantifiers can appear in formulas: Existential quantifier (). Universal quantifier (). Informally, a tuple variable t is bound if it is quantified, meaning that it appears in an ( t) or (t) clause; otherwise, it is free. Chapter 6: The Relational Algebra and Relational Calculus 47

57 Example Queries Using Existential Quantifier
Query 1: retrieve the name and address of all employees who work for the ‘Research’ department. Query 2: for every project located in ‘Stafford’, list the project number, the controlling department number, and the department manager’s last name, birth date, and address. Q1: {t.LNAME, t.FNAME, t.ADDRESS | EMPLOYEE(t) AND (d) (DEPARTMENT(d) AND d.DNAME=‘Research’ AND d.DNUMBER=t.DNO)} Q2: {p.PNUMBER, p.DNUM, m.LNAME, m.BDATE, m.ADDRESS| PROJECT(p) AND EMPLOYEE(m) AND p.PLOCATION=‘Stafford’ AND ((d)(DEPARTMENT(d) AND p.DNUM=d.DNUMBER AND d.MGRSSN=m.SSN))} Chapter 6: The Relational Algebra and Relational Calculus 48

58 Example Queries Using Existential Quantifier
Query 3: find the name of each employee who works on some project controlled by the department number 5. Query 4: list the names of managers who have at least one dependent. Q3: {e.LNAME, e.FNAME | EMPLOYEE(e) AND((x)(w) (PROJECT(x) AND WORKS_ON(w) AND x.DNUM=5 AND w.ESSN=e.SSN AND x.PNUMBER=w.PNO))} Q4: {e.LNAME, e.FNAME | EMPLOYEE(e) AND ((d) (p) (DEPARTMENT(d) AND DEPENDENT(p) AND e.SSN=d.MGRSSN AND p.ESSN=e.SSN))} Chapter 6: The Relational Algebra and Relational Calculus 49

59 Example Queries Using Existential Quantifier
Query 5: find the names of employees who have no dependents. Query 6: Make a list of project numbers for projects that involve an employee whose last name is ‘Smith’, either as a worker or as a manager of the controlling department for the project. Q5: {e.LNAME, e.FNAME | EMPLOYEE(e) AND (NOT (d) (DEPENDENT(d) AND e.SSN=d.ESSN))} Q6: {p.PNUMBER | PROJECT(p) AND (((e)(w) (EMPLOYEE(e) AND WORKS_ON(w) AND w.PNO=p.PNUMBER AND e.LNAME=‘Smith’ AND e.SSN=w.ESSN)) or ((m)(d)(EMPLOYEE(m) AND DEPARTMENT(d) AND p.DNUM=d.DNUMBER AND d.MGRSSN=m.SSN AND m.LNAME=‘Smith’)))} Chapter 6: The Relational Algebra and Relational Calculus 50

60 Introduction to Domain Relational Calculus
Domain calculus differs from tuple calculus in the type of variables used in formulas. Rather than having variables range over tuples, the variables range over single values from domains of attributes. Chapter 6: The Relational Algebra and Relational Calculus 51

61 Introduction to Domain Relational Calculus
Example: Retrieve the name and address of all employees who work for the ‘Research’ department. {qsv | (z) (l) (m) (EMPLOYEE(qrstuvwxyz) AND DEPARTMENT(lmno) AND l=‘Research’ AND m=z)} Example: for every project located in ‘Stafford’, list the project number, the controlling department number, and the department manager’s last name, birth date, and address. {iksuv | (j) (m) (n) (t) (PROJECT(hijk) AND EMPLOYEE(qrstuvwxyz) AND DEPARTMENT(lmno) AND k=m AND n=t AND j=‘Stafford’)} Chapter 6: The Relational Algebra and Relational Calculus 52

62 The Relational Calculus
The SQL language is based on the tuple relational calculus. The QBE language is based on the domain relational calculus. Chapter 6: The Relational Algebra and Relational Calculus 53


Download ppt "Introduction to Database Systems"

Similar presentations


Ads by Google