GTU MCA MATERIAL FOR DBMS II

RSS
  • Home
  • Quick Review
  • Assignment
  • Backup and Recovery
  • Differences
  • About Me

Monday, April 25, 2011

Relational Algebra

What is Relational Algebra?

1.    The relation algebra is a procedure query language.
2.    It consists of set of operation that takes one or two relation as input and produced a new relation as result.
3.    The select, project, and rename operation are called unary operation because they operate on one relation.
4.    Other operations operate on more than one relation and therefore it’s called binary operation.

Six basic operators:
·       Unary Operators
1)   Select    -  σ  (Sigma)
2)   Project   -  ∏ (PI)
3)    Rename -  ρ  (rho)
·       Binary Operators
1)    Union    -  U
2)    Set Difference - –
3)    Cartesian Product - X

Four Additional operators:
1)    Set intersection - ∩
2)    Natural join      -  
                    I.        Left Outer Join    -  
                  II.        Right Outer Join -  
                 III.        Full Outer Join   -
3)    Division - ÷
4)    Assignment - ←

Three Database Modification operators:
1)    Insert Operator  r ← r U E
2)    Delete Operator  r ← r – E
3)    Update Operator r ← ∏ F1,F2….Fn  (r)

Projection

Example:   (Table) EMPLOYEE

nrnamesalary
1John100
5Sarah300
7Tom100


SQLResultRelational algebra
select salary
from Employee
salary
100
300
∏salary(Employee)
select nr, salary
from Employee
nrsalary
1100
5300
7100
∏nr, salary(E)
Note that there are no duplicate rows in the result.

Selection


SQLResultRelational algebra
select *
from Employee
where salary < 200
nrnamesalary
1John100
7Tom100
σsalary < 200(Employee)
select *
from Employee
where salary < 200
and nr >= 7
nrnamesalary
7Tom100
σsalary < 200 and nr >= 7(Employee)

Cartesian product

The cartesian product of two tables combines each row in one table with each row in the other table.
Example: The table  (for EMPLOYEE)

enrenamedept
1ParagA
2KapilC
3DevenA
(DEPARTMENT)

dnrdname
AMarketing
BSales
CLegal

SQLResultRelational algebra
select *
from E, D
enrenamedeptdnrdname
1ParagAAMarketing
1ParagABSales
1ParagACLegal
2KapilCAMarketing
2KapilCBSales
2KapilCCLegal
3DevenAAMarketing
3DevenABSales
3DevenACLegal
Employee X Department

  • Seldom useful in practice.
  • Usually an error.
  • Can give a huge result.

The Natural join Operation:
  •   The Natural join is a binary operation that allows us to combine certain selections and Cartesian product into one operation.
  •   It is denoted by the join symbol ( ).
  •   The natural join operation forms a Cartesian product of its two arguments, performs a selection forcing equality on those attribute that appear in both relation, and removes the duplicate attributes.
Example
                                       EMP
Emp
No
Emp
Name
City
Salary
Deptno
1
Parag
Snagar
17000
10
2
Kapil
Sidhpur
18000
20
3
Deven
Junagadh
20000
10
4
Rahul
Rajkot
22000
30
5
Saurav
Jamnagar
35000
Null


    DEPT
Deptno
Deptname
Location
10
Computer
Ahmedabad
20
Account
Surat
30
Finance
Banglore
40
Research
Bombay
50
Marketing
Rajkot

∏ Emp.Empno,Empname,Salary,Deptname
 
(σEmp.deptno=dept.deptno (EMP                                DEPT))

Output:
Empno
Empname
Salary
Deptname
1
Parag
17000
Computer
2
Kapil
18000
Account
3
Deven
20000
Computer
4
Rahul
22000
Finance

  •   The result of this expression is shown in above table. Notice that we have lost the record about Saurav because he is not working in any department.
  •   Similarly, we have lost the record of deptno 40 and 50 from Dept because there is no employee working in deptno 40 and 50.
  •   In short, it returns record on base of deptno. 
 
Posted by Dr. Parag Shukla at 10:01:00 PM
Email This BlogThis! Share to X Share to Facebook

0 comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Total Pageviews

255056

Blog Archive

  • ►  2019 (1)
    • ►  March (1)
  • ►  2016 (7)
    • ►  August (6)
    • ►  July (1)
  • ▼  2011 (16)
    • ►  May (2)
    • ▼  April (6)
      • Basic of Join
      • Relational Algebra
      • Speed Up Vs Scale Up
      • Assignment - 5 Introduction to Other Databases
      • Mid Term Exam Feedback
      • Assignment - 4 Database Security
    • ►  March (5)
    • ►  February (3)
  • ►  2010 (9)
    • ►  May (4)
    • ►  March (5)
  • ►  2009 (1)
    • ►  December (1)

Followers

Blog List

Search

Parag Shukla. Powered by Blogger.

Popular Posts

  • Serial Schedule Vs Non-Serial Schedule
    Serial Schedule Non-Serial Schedule A serial schedule is a sequence of operat...
  • Dirty Read Vs Unrepeatable Read
    Dirty Read Unrepeatable Read A dirty read problem occurs when one transaction updates a ...
  • Log Based Recovery
    Log Based Recovery The most widely used structure for recording database modification is the log. The log is a sequence of log ...
  • Lost Update Vs Uncommitted Data
    Lost Update Uncommitted Data This problem is also known as “Multiple Update...
  • Shadow Paging
    Shadow Paging This technique does not require LOG in single user environment In mult...
  • Starvation Vs Deadlock
    Starvation Deadlock Starvation happens if same transaction is always choosen ...
  • Checkpoints
    Checkpoints When System failure occurs o We must consult log to determine those transaction that need to be redone and those tra...
  • Defferred Update method
    Deferred update Do not physically update the database on disk until after a transaction reaches its commit point; Then updates are r...
  • Assignment - 7 Query Processing & Optimization
    Assignment – 7         Query Processing & optimization    Submission Date 30-05-11   Q-1. Explain th...
  • Immediate Update Method
    Immediate update technique Database may be updated by some operations of a transaction before the transaction reaches its commit poi...
Copyright © 2010 GTU MCA MATERIAL FOR DBMS II