SlideShare uma empresa Scribd logo
1 de 17
Unit-I
Database
Management
System
(6KS02)
LESSON .4
Topics to be Cover:
The Relational Algebra:
 Fundamental Operations:
 .. The Select Operation
 .. The Project Operation
 ..Composition of Relational Operations
 ..The Union Operations
Learning Objectives
 Understanding the Concept of Procedural Query Language
 Understanding the Select, Project and Composition of relational
Operations.
 Understanding the Union Operations
The Relational Algebra
 The Relational algebra is procedural query language.
It consists of a set of operations that take one ortwo
relations as input and produce new relation as their
result.
• Six basic operators
• select: σ
• project: ∏
• union: ∪
• set difference: –
• Cartesian product: x
• rename: ρ
 The Select project , and
rename operations are called
unary operations, because they
operate on one relation.
The otherthree operations
operate on pairs of relations
and are called binary
operations.
 Select Operation:
consider sample relation
loan with schema given as
Loan-schema=(loan-number,
branch-name,amount)
 The select operation selects tuples that satisfy a given predicate.
We use the lowercase Greek letter sigma (σ) to denote selection.
The predicate appears as a subscript to σ. and relation followed by
parenthesis.
 Thus, to select those tuples of the loan relation where the branch
is “Perryridge,” we write
σbranch-name =“Perryridge”(loan)
 We can find all tuples in which the amount lent is more than
 Select Operation:
consider sample relation
loan with schema given as
Loan-schema=(loan-number,
branch-name,amount)
 In general, we allow comparisons using =, =, <, ≤, >, ≥ in the
selection predicate.
 Furthermore, we can combine several predicates into a larger
predicate by using the connectives and (∧), or (∨), and not ( ¬ ).
Thus, to find those tuples pertaining to loans of more than $1200
made by the Perryridge branch, we write
σbranch-name=“Perryridge” amount>∧ 1200 (loan)
Project Operation:
Suppose we want to list all loan numbers and the amount of the
loans, but do not care about the branch name.
The project operation allows us to produce this relation. The
project operation is a unary operation that returns its argument
relation, with
certain attributes left out.
Projection is denoted by the uppercase Greek letter pi (Π).
We list those attributes that we wish to appear in the result as a
subscript to Π. The argument relation follows in parentheses.
Thus, we write the query to list all loan numbers and the amount
of the loan as
Πloan-number,amount(loan)
result?
Composition of Relational Operations
The fact that the result of a relational
operation is itself a relation
is important.
Consider the more complicated query
“Find those customers who live in Harrison.” We write:
Πcustomer-name (σcustomer-city=“Harrison” (customer))
Notice that, instead of giving the name of a relation as the argument
of the projection operation, we give an expression that evaluates to a
relation.
Union Operation:
Consider a query to find the names of all bank customers who have
either an account or a loan or both. To answer this query, we need
the information in the depositor relation (Figure 3.5) and in the
borrower relation (Figure 3.7).
We know how to find the names
of all customers with a loan in the bank
Πcustomer-name(borrower)
We also know how to find the names
of all customers with an account in the bank:
Πcustomer-name(depositor)
Union Operation:
To answer the query, we need the union of these two sets; that is, we need all
customer names that appear in either or both of the two relations.
 We find these data by the binary operation union, denoted, as in set theory, by ∪.
So the expression needed is
Πcustomer-name(borrower ) ∪ Πcustomer-name (depositor)
The result relation for this query appears in Figure
Notice that there are 10 tuples in the result, even though
there are seven distinct borrowers and six depositors.
This apparent discrepancy occurs because Smith,
Jones, and Hayes are borrowers as well as depositors.
Since relations are sets, duplicate values are eliminated.
The Set Difference Operation
The set-difference operation, denoted by −, allows us to find tuples
that are in one relation but are not in another.
 The expression r − s produces a relation containing those tuples in
r but not in s.
We can find all customers of the
bank who have an account
but not a loan by writing
Πcustomer-name (depositor) − Πcustomer-name(borrower )
The result relation for
this query appears in Figure 3.13.
The Cartesian Product Operation
The Cartesian-product operation, denoted by a cross (×), allows
us to combine information from any two relations. We write the
Cartesian product of relations r1 and r2 as r1 × r2.
For example, the relation schema for r = borrower × loan is
(borrower.customer-name, borrower.loan-number, loan.loan-number,
loan.branch-name, loan.amount)
The Cartesian Product Operation
The Cartesian Product Operation
Suppose that we want to find the names of all customers who have
a loan at the Perryridge branch.
We need the information
in both the loan relation
and the borrower relation
to do so.
σbranch-name =“Perryridge”(borrower × loan)
The Rename Operation
Unlike relations in the database, the results of relational-algebra expressions do
not have a name that we can use to refer to them. It is useful to be able to give
them names; the rename operator,
denoted by the lowercase Greek letter rho (ρ),
Given a relational-algebra expression E, the expression
ρx(E) returns the result of expression E under the name x.
Thus, we can also apply the rename operation to a relation r to get the same
relation under a new name.
A second form of the rename operation is as follows.
ρx(A1,A2,...,An)(E)
returns the result of expression E under the name x, and with the attributes
renamed to A1,A2, . . .,An.
What we Learned?
 Database Schema
 Relation
 Keys Concepts in Database
 Query languages.
HOMEWORK
 Explain the Keys Concepts in Database.
 What is Database Schema.

Mais conteúdo relacionado

Mais procurados

3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
koolkampus
 
Relational algebra
Relational algebraRelational algebra
Relational algebra
shynajain
 

Mais procurados (20)

Additional Relational Algebra Operations
Additional Relational Algebra OperationsAdditional Relational Algebra Operations
Additional Relational Algebra Operations
 
CHAPTER 2 DBMS IN EASY WAY BY MILAN PATEL
CHAPTER 2 DBMS IN EASY WAY BY  MILAN PATELCHAPTER 2 DBMS IN EASY WAY BY  MILAN PATEL
CHAPTER 2 DBMS IN EASY WAY BY MILAN PATEL
 
normalization
normalizationnormalization
normalization
 
ch5
ch5ch5
ch5
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
 
Ex
ExEx
Ex
 
Lllll
LllllLllll
Lllll
 
Dbms ER Model
Dbms ER ModelDbms ER Model
Dbms ER Model
 
Cs501 rel algebra
Cs501 rel algebraCs501 rel algebra
Cs501 rel algebra
 
ch6
ch6ch6
ch6
 
1643 y є r relational calculus-1
1643 y є r  relational calculus-11643 y є r  relational calculus-1
1643 y є r relational calculus-1
 
Relational algebra
Relational algebraRelational algebra
Relational algebra
 
Relation model part 1
Relation model part 1Relation model part 1
Relation model part 1
 
Functional dependency and normalization
Functional dependency and normalizationFunctional dependency and normalization
Functional dependency and normalization
 
DBMS CS2
DBMS CS2DBMS CS2
DBMS CS2
 
ch14
ch14ch14
ch14
 
one to one function
one to one functionone to one function
one to one function
 
Normalization
NormalizationNormalization
Normalization
 
Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013
 
Oop
OopOop
Oop
 

Destaque

Database Design Slide 1
Database Design Slide 1Database Design Slide 1
Database Design Slide 1
ahfiki
 
Types of databases
Types of databasesTypes of databases
Types of databases
PAQUIAAIZEL
 

Destaque (12)

COMPUTER PROGRAMMING UNIT 1 Lecture 6
COMPUTER PROGRAMMING UNIT 1 Lecture 6COMPUTER PROGRAMMING UNIT 1 Lecture 6
COMPUTER PROGRAMMING UNIT 1 Lecture 6
 
COMPUTER PROGRAMMING UNIT 1 Lecture 5
COMPUTER PROGRAMMING UNIT 1 Lecture 5COMPUTER PROGRAMMING UNIT 1 Lecture 5
COMPUTER PROGRAMMING UNIT 1 Lecture 5
 
COMPUTER PROGRAMMING UNIT 1 Lecture 4
COMPUTER PROGRAMMING UNIT 1 Lecture 4COMPUTER PROGRAMMING UNIT 1 Lecture 4
COMPUTER PROGRAMMING UNIT 1 Lecture 4
 
COMPUTER PROGRAMMING UNIT 1 Lecture 1
COMPUTER PROGRAMMING UNIT 1 Lecture 1COMPUTER PROGRAMMING UNIT 1 Lecture 1
COMPUTER PROGRAMMING UNIT 1 Lecture 1
 
Important Questions of fourier series with theoretical study Engg. Mathem...
Important Questions  of  fourier series with theoretical study   Engg. Mathem...Important Questions  of  fourier series with theoretical study   Engg. Mathem...
Important Questions of fourier series with theoretical study Engg. Mathem...
 
Database Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance AnalysisDatabase Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance Analysis
 
COMPUTER PROGRAMMING UNIT 1 Lecture 3
COMPUTER PROGRAMMING UNIT 1 Lecture 3COMPUTER PROGRAMMING UNIT 1 Lecture 3
COMPUTER PROGRAMMING UNIT 1 Lecture 3
 
COMPUTER PROGRAMMING UNIT 1 Lecture 2
COMPUTER PROGRAMMING UNIT 1 Lecture 2COMPUTER PROGRAMMING UNIT 1 Lecture 2
COMPUTER PROGRAMMING UNIT 1 Lecture 2
 
Computer Programming- Lecture 5
Computer Programming- Lecture 5 Computer Programming- Lecture 5
Computer Programming- Lecture 5
 
Sucess
SucessSucess
Sucess
 
Database Design Slide 1
Database Design Slide 1Database Design Slide 1
Database Design Slide 1
 
Types of databases
Types of databasesTypes of databases
Types of databases
 

Semelhante a Database system by VISHAL PATIL

Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01
Ankit Dubey
 
Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01
Ankit Dubey
 

Semelhante a Database system by VISHAL PATIL (20)

SQL PPT.ppt
SQL PPT.pptSQL PPT.ppt
SQL PPT.ppt
 
3.ppt
3.ppt3.ppt
3.ppt
 
relational model in Database Management.ppt.ppt
relational model in Database Management.ppt.pptrelational model in Database Management.ppt.ppt
relational model in Database Management.ppt.ppt
 
Ch4
Ch4Ch4
Ch4
 
Details of RDBMS.ppt
Details of RDBMS.pptDetails of RDBMS.ppt
Details of RDBMS.ppt
 
dbms first unit
dbms first unitdbms first unit
dbms first unit
 
Relational algebra operations
Relational algebra operationsRelational algebra operations
Relational algebra operations
 
Sql server select queries ppt 18
Sql server select queries ppt 18Sql server select queries ppt 18
Sql server select queries ppt 18
 
ch2
ch2ch2
ch2
 
DBMS ppt (1).pptx
DBMS ppt (1).pptxDBMS ppt (1).pptx
DBMS ppt (1).pptx
 
Module 2 - part i
Module   2 - part iModule   2 - part i
Module 2 - part i
 
Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
 
Unit04 dbms
Unit04 dbmsUnit04 dbms
Unit04 dbms
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
Dbms 11: Relational Algebra
Dbms 11: Relational AlgebraDbms 11: Relational Algebra
Dbms 11: Relational Algebra
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data Model
 
Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01
 
Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01
 
Relational algebra-and-relational-calculus
Relational algebra-and-relational-calculusRelational algebra-and-relational-calculus
Relational algebra-and-relational-calculus
 
Ch3 a
Ch3 aCh3 a
Ch3 a
 

Último

1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
AldoGarca30
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 

Último (20)

Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 

Database system by VISHAL PATIL

  • 2. LESSON .4 Topics to be Cover: The Relational Algebra:  Fundamental Operations:  .. The Select Operation  .. The Project Operation  ..Composition of Relational Operations  ..The Union Operations
  • 3. Learning Objectives  Understanding the Concept of Procedural Query Language  Understanding the Select, Project and Composition of relational Operations.  Understanding the Union Operations
  • 4. The Relational Algebra  The Relational algebra is procedural query language. It consists of a set of operations that take one ortwo relations as input and produce new relation as their result. • Six basic operators • select: σ • project: ∏ • union: ∪ • set difference: – • Cartesian product: x • rename: ρ  The Select project , and rename operations are called unary operations, because they operate on one relation. The otherthree operations operate on pairs of relations and are called binary operations.
  • 5.  Select Operation: consider sample relation loan with schema given as Loan-schema=(loan-number, branch-name,amount)  The select operation selects tuples that satisfy a given predicate. We use the lowercase Greek letter sigma (σ) to denote selection. The predicate appears as a subscript to σ. and relation followed by parenthesis.  Thus, to select those tuples of the loan relation where the branch is “Perryridge,” we write σbranch-name =“Perryridge”(loan)  We can find all tuples in which the amount lent is more than
  • 6.  Select Operation: consider sample relation loan with schema given as Loan-schema=(loan-number, branch-name,amount)  In general, we allow comparisons using =, =, <, ≤, >, ≥ in the selection predicate.  Furthermore, we can combine several predicates into a larger predicate by using the connectives and (∧), or (∨), and not ( ¬ ). Thus, to find those tuples pertaining to loans of more than $1200 made by the Perryridge branch, we write σbranch-name=“Perryridge” amount>∧ 1200 (loan)
  • 7. Project Operation: Suppose we want to list all loan numbers and the amount of the loans, but do not care about the branch name. The project operation allows us to produce this relation. The project operation is a unary operation that returns its argument relation, with certain attributes left out. Projection is denoted by the uppercase Greek letter pi (Π). We list those attributes that we wish to appear in the result as a subscript to Π. The argument relation follows in parentheses. Thus, we write the query to list all loan numbers and the amount of the loan as Πloan-number,amount(loan) result?
  • 8. Composition of Relational Operations The fact that the result of a relational operation is itself a relation is important. Consider the more complicated query “Find those customers who live in Harrison.” We write: Πcustomer-name (σcustomer-city=“Harrison” (customer)) Notice that, instead of giving the name of a relation as the argument of the projection operation, we give an expression that evaluates to a relation.
  • 9. Union Operation: Consider a query to find the names of all bank customers who have either an account or a loan or both. To answer this query, we need the information in the depositor relation (Figure 3.5) and in the borrower relation (Figure 3.7). We know how to find the names of all customers with a loan in the bank Πcustomer-name(borrower) We also know how to find the names of all customers with an account in the bank: Πcustomer-name(depositor)
  • 10. Union Operation: To answer the query, we need the union of these two sets; that is, we need all customer names that appear in either or both of the two relations.  We find these data by the binary operation union, denoted, as in set theory, by ∪. So the expression needed is Πcustomer-name(borrower ) ∪ Πcustomer-name (depositor) The result relation for this query appears in Figure Notice that there are 10 tuples in the result, even though there are seven distinct borrowers and six depositors. This apparent discrepancy occurs because Smith, Jones, and Hayes are borrowers as well as depositors. Since relations are sets, duplicate values are eliminated.
  • 11. The Set Difference Operation The set-difference operation, denoted by −, allows us to find tuples that are in one relation but are not in another.  The expression r − s produces a relation containing those tuples in r but not in s. We can find all customers of the bank who have an account but not a loan by writing Πcustomer-name (depositor) − Πcustomer-name(borrower ) The result relation for this query appears in Figure 3.13.
  • 12. The Cartesian Product Operation The Cartesian-product operation, denoted by a cross (×), allows us to combine information from any two relations. We write the Cartesian product of relations r1 and r2 as r1 × r2. For example, the relation schema for r = borrower × loan is (borrower.customer-name, borrower.loan-number, loan.loan-number, loan.branch-name, loan.amount)
  • 14. The Cartesian Product Operation Suppose that we want to find the names of all customers who have a loan at the Perryridge branch. We need the information in both the loan relation and the borrower relation to do so. σbranch-name =“Perryridge”(borrower × loan)
  • 15. The Rename Operation Unlike relations in the database, the results of relational-algebra expressions do not have a name that we can use to refer to them. It is useful to be able to give them names; the rename operator, denoted by the lowercase Greek letter rho (ρ), Given a relational-algebra expression E, the expression ρx(E) returns the result of expression E under the name x. Thus, we can also apply the rename operation to a relation r to get the same relation under a new name. A second form of the rename operation is as follows. ρx(A1,A2,...,An)(E) returns the result of expression E under the name x, and with the attributes renamed to A1,A2, . . .,An.
  • 16. What we Learned?  Database Schema  Relation  Keys Concepts in Database  Query languages.
  • 17. HOMEWORK  Explain the Keys Concepts in Database.  What is Database Schema.