0% found this document useful (0 votes)
65 views

Tutorial Relational Algebra: All The Relation Algebra Expressions Base On The Following Database Schema

This 3-page document provides examples of queries in relational algebra procedural form and as single expressions. It also provides sample relational algebra expressions, including retrieving employee names with no dependents, listing project details for projects located in "Colombo", and finding names of employees who work on all projects controlled by department 5. The document is titled "Tutorial Relational Algebra" and is from a 2012 database management systems class.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

Tutorial Relational Algebra: All The Relation Algebra Expressions Base On The Following Database Schema

This 3-page document provides examples of queries in relational algebra procedural form and as single expressions. It also provides sample relational algebra expressions, including retrieving employee names with no dependents, listing project details for projects located in "Colombo", and finding names of employees who work on all projects controlled by department 5. The document is titled "Tutorial Relational Algebra" and is from a 2012 database management systems class.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CST 222-2 Database Management Systems

2012

Tutorial Relational Algebra

All the Relation Algebra expressions base on the following database schema.

Page 1 of 3

CST 222-2 Database Management Systems

2012

Examples of Queries in Relational Algebra: Procedural Form


Retrieve the name and address of all employees who work for the Research department. RESEARCH_DEPT DNAME=Research (DEPARTMENT) RESEARCH_EMPS (RESEARCH_DEPT DNUMBER= DNOEMPLOYEEEMPLOYEE) RESULT FNAME, LNAME, ADDRESS (RESEARCH_EMPS)

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)

Examples of Queries in Relational Algebra Single expressions


Retrieve the name and address of all employees who work for the Research department. Fname, Lname, Address ( Dname= Research (DEPARTMENT Dnumber=Dno(EMPLOYEE))

Retrieve the names of employees who have no dependents. Lname, Fname(( Ssn (EMPLOYEE) Ssn ( Essn (DEPENDENT))) EMPLOYEE)

Sample Relational Algebra expressions


For every project located in Colombo list the project number, the controlling department number and the dept managers last name, address and bdate. Colombo_Projs <- Plocation= Colombo (Project) Contr_Dept<-(Colombo_Projs Dnum=Dnumber Department)

Proj_Dept_Mgr <-(Contr_Dept MgrId=Empid Employee) Result<- Pnumber,Dnum,Lanme,Address,Bdate(Proj_Dept_Mgr)

Find the names of employees who work on all the projects controlled by dept. no. 5 Dept5_Projs(Pno)<- Pnumber( Dnum=5(Project))
Page 2 of 3

CST 222-2 Database Management Systems


Emp_Proj(Empid,Pno)<- Essn,Pno ( Works_on) Result_Emp_Empid<-(Emp_ProjDept5_Proj) Result<- Lname,Fname(Result_Emp_Empid*Employee) Retrieve the name of employees who have no dependents. All_emps <- SSN(Employee) Emps_with_deps(SSN) <- ESSN(Dependent) Emps_without_deps<-(All_empsEmps_with_deps) Result <- Lname, Fname (Emps_without_deps* Employee)

2012

List the names of managers who have at least one dependent. Mgrs(SSN) <- MGRSSN(Department) Emps_with_deps(SSN)<- ESSN(Dependent) Mgrs_with_deps <- (Mgrs Emps_with_deps) Result <- Lname, Fname (Mgrs_with_deps*Employee)

Page 3 of 3

You might also like