Dbms Seminar Report
Dbms Seminar Report
CHAPTER 1
INTRODUCTION
Relational algebra serves as the foundation upon which modern database systems are
constructed, offering a systematic approach to querying and manipulating data. Within the
relational model, data is organized into tables (relations), and relational algebra provides a
set of operations to perform queries on these tables. Through operations such as selection,
projection, join, and set operations, users can formulate complex queries to extract
specific information from databases.
CHAPTER 2
NOTE: Outer Union Is Equivalent to A Full Outer Join if the Join Attributes Are All the
Com Mon Attributes of The Two Relations. This query could be specified in other ways;
for example, the order of the JOIN and SELECT operations could be reversed, or the
JOIN could be replaced by a NATURAL JOIN after renaming one of the join attributes to
match the other join attribute name.
STAFFORD_PROJS ← σPlocation=‘Stafford’(PROJECT)
CONTR_DEPTS ← (STAFFORD_PROJS Dnum=DnumberDEPARTMENT)
PROJ_DEPT_MGRS ← (CONTR_DEPTS Mgr_ssn=SsnEMPLOYEE)
In this example, we first select the projects located in Stafford, then join them with their
controlling departments, and then join the result with the department managers. Finally,
we apply a project operation on the desired attributes.
DEPT5_PROJS ← ρ(Pno)(πPnumber(σDnum=5(PROJECT)))
EMP_PROJ ← ρ(Ssn, Pno)(πEssn, Pno(WORKS_ON))
RESULT_EMP_SSNS ← EMP_PROJ ÷ DEPT5_PROJS
RESULT ← πLname, Fname(RESULT_EMP_SSNS * EMPLOYEE)
In this query, we first create a table DEPT5_PROJS that contains the project numbers of
all projects controlled by department 5. Then we create a table EMP_PROJ that holds
(Ssn, Pno) tuples, and apply the division operation [2]. Notice that we renamed the
attributes so that they will be correctly used in the division operation. Finally, we join the
result of the division, which holds only Ssn values, with the EMPLOYEE table to retrieve
the Fname, Lname attributes from EMPLOYEE.
In this query, we retrieved the project numbers for projects that involve an employee
named Smith as a worker in SMITH_WORKER_PROJS. Then we retrieved the project
numbers for projects that involve an employee named Smith as manager of the
department that controls the project in SMITH_MGR_PROJS. Finally, we applied the
UNION operation on SMITH_WORKER_PROJS and SMITH_MGR_PROJS. As a
single in-line expression, this query becomes
DEPT. OF AIML, AIET 3|Page
DATABASE MANAGEMENT SYSTEMS / 21CS53 SEMINAR REPORT
Strictly speaking, this query cannot be done in the basic (original) relational algebra [3].
We have to use the AGGREGATE FUNCTION operation with the COUNT aggregate
function. We assume that dependents of the same employee have distinct
Dependent_name values.
This is an example of the type of query that uses the MINUS (SET DIFFERENCE)
operation.
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)
We first retrieve a relation with all employee Ssns in ALL_EMPS. Then we create a table
with the Ssns of employees who have at least one dependent in EMPS_WITH_DEPS.
Then we apply the SET DIFFERENCE operation to retrieve employees Ssns with no
dependents in EMPS_WITHOUT_DEPS, and finally join this with EMPLOYEE to
retrieve the desired attributes. As a single in-line expression, this query becomes
MGRS(Ssn) ← πMgr_ssn(DEPARTMENT)
EMPS_WITH_DEPS(Ssn) ← πEssn(DEPENDENT)
In this query, we retrieve the Ssns of managers in MGRS, and the Ssns of employees with
at least one dependent in EMPS_WITH_DEPS, then we apply the SET INTERSECTION
operation to get the Ssns of managers who have at least one dependent. As we mentioned
earlier, the same query can be specified in many different ways in relational algebra [4].
In particular, the operations can often be applied in various orders.
CHAPTER 3
CONCLUSION
Relational algebra exemplifies the elegance and efficiency of relational database
management, offering a standardized approach to data manipulation. Each example
discussed showcases the adaptability of relational algebra operations in solving different
data retrieval challenges, from selecting employees based on departmental affiliation to
identifying projects managed by specific departments.
REFERENCES
[1] https://mail.google.com/mail/u/0/tab=rm&ogbl#inbox/
FMfcgzGxSHlNLXjpwxvlDJTcbnSJmcXs?projector=1&messagePartId=0.1
[2] https://mail.google.com/mail/u/0/tab=rm&ogbl#inbox/
FMfcgzGxSHlNLZqdJNkwtrWjLxCpPBrL?projector=1&messagePartId=0.1
[3] https://mail.google.com/mail/u/0/tab=rm&ogbl#inbox/
FMfcgzGxSHlNLZqdTMnPhvLsGFhntjnJ?projector=1&messagePartId=0.1
[4] https://mail.google.com/mail/u/0/tab=rm&ogbl#inbox/
FMfcgzGxSHlNLZqmTgwsFjzChWvFBBzh?projector=1&messagePartId=0.1