SlideShare a Scribd company logo
1 of 13
Download to read offline
Dr. Amiya Ranjan Panda
Assistant Professor [II]
School of Computer Engineering,
Kalinga Institute of Industrial Technology (KIIT),
Deemed to be University,Odisha
Relational Calculus
KALINGA INSTITUTE OF INDUSTRIAL
TECHNOLOGY
School Of Computer
Engineering
4 Credit Lecture Note 14
Chapter Contents
q Relational Calculus
q Tuple Relational Calculus
q Safe Expressions
q Queries
q Domain Relational Calculus
q Queries
2
Ø Relational calculus is non-procedural.
Ø In relational calculus, a query is solved by defining a solution relation in a
single step.
Ø Relational calculus is mainly based on the well-known propositional calculus,
which is a method of calculating with sentences or declarations.
Ø Various types of relational calculus are:
ü Tuple Relational Calculus (TRC)
ü Domain Relational Calculus (DRC)
3
Relational Calculus
Ø A tuple variable is a variable that takes on tuples of a particular relation schema
as values.
Ø A tuple relational calculus query has the form: {T/ P(T)}
Ø The result of this query is the set of all tuples t for which the formula P(T)
evaluates to TRUE with T = t
Sailors (sid, sname, rating, age)
Query: Find all the sailors with a rating above 4
{S/S ∈ Sailors ∧ S.rating > 4}
4
Tuple Relational Calculus
Ø Let Rel → be a relation name, R, S → be the tuple variables, a → an attribute
of R, b → an attribute of S, op → operator in the set {<, ≤, >, ≥, =, ^=}. An
Atomic formula is one of the following:
ü R ∈ Rel
ü R.a op S.b
ü R.a op Constant or Constant op R.a
Ø To represent the join and division of relational algebra by relational calculus,
we need quantifiers such as: existential for join and universal for division.
Ø A quantifier quantifies or indicates the quantity of something.
Ø The existential quantifier (∃) states that at least one instance of a particular
type of thing exist Similarly, the universal quantifier (∀) states that some
condition applies to all or to every row of some type.
Ø A formula is recursively defined by using the following rules:
ü Any atomic formula
ü If p and q are formulae, then ¬ p, p ∧ q, p ∨ q, or p ⇒ q are also
formulae
ü If p is a formula that contains T as a variable, then ∃ T(p) and ∀ T(p) are
also formulae.
5
Tuple Relational Calculus
Ø The quantifiers ∃ and ∀ are said to bind the tuple variable R; whereas a
variable is said to be free in a formula if the formula does not contain an
occurrence of a quantifier that binds it.
Ø In most of the queries, the output is shown by using the free variables.
Ø Safe Expressions: Whenever we use universal quantifiers or existential
quantifiers in a calculus expression, we must make sure that the resulting
expression makes sense.
Ø A safe expression in relational calculus is one that is guaranteed to yield a
finite number of tuples as its result; otherwise, the expression is called unsafe.
Ø That means, an expression is said to be safe if all values in its result are from
the domain of the expression.
6
Tuple Relational Calculus
7
Queries
8
Queries…
9
Queries…
Ø In tuple relational calculus, the variables range over the tuples whereas in
domain relational calculus, the variables range over the domains.
Ø Let Rel → be a relation name, X, Y → be the domain variables, op → an
operator in the set {<, ≤, >, ≥, =, ^=}. An Atomic formula in domain relational
calculus is one of the following:
ü <x1, x2, ... xn > ∈ Rel
ü X op Y
ü X op Constant or Constant op X
Ø A formula is recursively defined by using the following rules:
üAny atomic formula
üIf p and q are formulae, then ¬p, p ∧ q, p ∨ q, or p ⇒ q are also formulae
üIf p is a formula that contains X as a domain variable, then ∃X(p) and ∀
X(p) are also formulae
Ø The quantifiers ∃ & ∀ are said to bind the domain variable X. Whereas a
variable is said to be free in a formula if the formula does not contain an
occurrence of a quantifier that binds it.
10
Domain Relational Calculus (DRC)
11
Queries
12
Queries…
13

More Related Content

What's hot

Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)
yourbookworldanil
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
koolkampus
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
koolkampus
 

What's hot (20)

Decomposition using Functional Dependency
Decomposition using Functional DependencyDecomposition using Functional Dependency
Decomposition using Functional Dependency
 
serializability in dbms
serializability in dbmsserializability in dbms
serializability in dbms
 
Relational Calculus
Relational CalculusRelational Calculus
Relational Calculus
 
Lossless decomposition
Lossless decompositionLossless decomposition
Lossless decomposition
 
Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
 
Databases: Normalisation
Databases: NormalisationDatabases: Normalisation
Databases: Normalisation
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Language and Processors for Requirements Specification
Language and Processors for Requirements SpecificationLanguage and Processors for Requirements Specification
Language and Processors for Requirements Specification
 
Introduction to distributed database
Introduction to distributed databaseIntroduction to distributed database
Introduction to distributed database
 
ER-Model-ER Diagram
ER-Model-ER DiagramER-Model-ER Diagram
ER-Model-ER Diagram
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
Database systems - Chapter 2
Database systems - Chapter 2Database systems - Chapter 2
Database systems - Chapter 2
 
recursive transition_networks
recursive transition_networksrecursive transition_networks
recursive transition_networks
 
Generalization and specialization
Generalization and specializationGeneralization and specialization
Generalization and specialization
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 

Similar to Dbms 14: Relational Calculus

20220818151924_PPT01 - The Logic of Compound and Quantitative Statement.pptx
20220818151924_PPT01 - The Logic of Compound and Quantitative Statement.pptx20220818151924_PPT01 - The Logic of Compound and Quantitative Statement.pptx
20220818151924_PPT01 - The Logic of Compound and Quantitative Statement.pptx
ssuser92109d
 
Discrete structures &amp; optimization unit 1
Discrete structures &amp; optimization unit 1Discrete structures &amp; optimization unit 1
Discrete structures &amp; optimization unit 1
SURBHI SAROHA
 
logicproof-141212042039-conversion-gate01.pdf
logicproof-141212042039-conversion-gate01.pdflogicproof-141212042039-conversion-gate01.pdf
logicproof-141212042039-conversion-gate01.pdf
PradeeshSAI
 

Similar to Dbms 14: Relational Calculus (20)

Slide subtopic 4
Slide subtopic 4Slide subtopic 4
Slide subtopic 4
 
dma_ppt.pdf
dma_ppt.pdfdma_ppt.pdf
dma_ppt.pdf
 
UGC NET Computer Science & Application book.pdf [Sample]
UGC NET Computer Science & Application book.pdf  [Sample]UGC NET Computer Science & Application book.pdf  [Sample]
UGC NET Computer Science & Application book.pdf [Sample]
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Computational logic First Order Logic_part2
Computational logic First Order Logic_part2Computational logic First Order Logic_part2
Computational logic First Order Logic_part2
 
1643 y є r relational calculus-1
1643 y є r  relational calculus-11643 y є r  relational calculus-1
1643 y є r relational calculus-1
 
20220818151924_PPT01 - The Logic of Compound and Quantitative Statement.pptx
20220818151924_PPT01 - The Logic of Compound and Quantitative Statement.pptx20220818151924_PPT01 - The Logic of Compound and Quantitative Statement.pptx
20220818151924_PPT01 - The Logic of Compound and Quantitative Statement.pptx
 
1. linear model, inference, prediction
1. linear model, inference, prediction1. linear model, inference, prediction
1. linear model, inference, prediction
 
L2.pdf
L2.pdfL2.pdf
L2.pdf
 
leanCoR: lean Connection-based DL Reasoner
leanCoR: lean Connection-based DL ReasonerleanCoR: lean Connection-based DL Reasoner
leanCoR: lean Connection-based DL Reasoner
 
Lecture-3-and-4.pdf
Lecture-3-and-4.pdfLecture-3-and-4.pdf
Lecture-3-and-4.pdf
 
A Systematic Approach To Probabilistic Pointer Analysis
A Systematic Approach To Probabilistic Pointer AnalysisA Systematic Approach To Probabilistic Pointer Analysis
A Systematic Approach To Probabilistic Pointer Analysis
 
Statistics 1 revision notes
Statistics 1 revision notesStatistics 1 revision notes
Statistics 1 revision notes
 
2. diagnostics, collinearity, transformation, and missing data
2. diagnostics, collinearity, transformation, and missing data 2. diagnostics, collinearity, transformation, and missing data
2. diagnostics, collinearity, transformation, and missing data
 
Trc final
Trc finalTrc final
Trc final
 
Discrete structures &amp; optimization unit 1
Discrete structures &amp; optimization unit 1Discrete structures &amp; optimization unit 1
Discrete structures &amp; optimization unit 1
 
logicproof-141212042039-conversion-gate01.pdf
logicproof-141212042039-conversion-gate01.pdflogicproof-141212042039-conversion-gate01.pdf
logicproof-141212042039-conversion-gate01.pdf
 
DISMATH_Part1
DISMATH_Part1DISMATH_Part1
DISMATH_Part1
 
Mathematical Logic
Mathematical LogicMathematical Logic
Mathematical Logic
 
Polynomials
PolynomialsPolynomials
Polynomials
 

More from Amiya9439793168

More from Amiya9439793168 (11)

Dbms 13: Query Using Relational Algebra
Dbms 13: Query Using Relational AlgebraDbms 13: Query Using Relational Algebra
Dbms 13: Query Using Relational Algebra
 
Dbms 12: Join
Dbms 12: JoinDbms 12: Join
Dbms 12: Join
 
Dbms 11: Relational Algebra
Dbms 11: Relational AlgebraDbms 11: Relational Algebra
Dbms 11: Relational Algebra
 
Dbms 10: Conversion of ER model to Relational Model
Dbms 10: Conversion of ER model to Relational ModelDbms 10: Conversion of ER model to Relational Model
Dbms 10: Conversion of ER model to Relational Model
 
Dbms 9: Relational Model
Dbms 9: Relational ModelDbms 9: Relational Model
Dbms 9: Relational Model
 
Dbms 8: Enhanced ER Model
Dbms 8: Enhanced ER ModelDbms 8: Enhanced ER Model
Dbms 8: Enhanced ER Model
 
Dbms 6: ER Modeling
Dbms 6: ER ModelingDbms 6: ER Modeling
Dbms 6: ER Modeling
 
Dbms 3: 3 Schema Architecture
Dbms 3: 3 Schema ArchitectureDbms 3: 3 Schema Architecture
Dbms 3: 3 Schema Architecture
 
Dbms 2: Data Model
Dbms 2: Data ModelDbms 2: Data Model
Dbms 2: Data Model
 
Introduction to Database Management System
Introduction to Database Management SystemIntroduction to Database Management System
Introduction to Database Management System
 
Dbms 7: ER Diagram Design Issue
Dbms 7: ER Diagram Design IssueDbms 7: ER Diagram Design Issue
Dbms 7: ER Diagram Design Issue
 

Recently uploaded

notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 

Recently uploaded (20)

NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 

Dbms 14: Relational Calculus

  • 1. Dr. Amiya Ranjan Panda Assistant Professor [II] School of Computer Engineering, Kalinga Institute of Industrial Technology (KIIT), Deemed to be University,Odisha Relational Calculus KALINGA INSTITUTE OF INDUSTRIAL TECHNOLOGY School Of Computer Engineering 4 Credit Lecture Note 14
  • 2. Chapter Contents q Relational Calculus q Tuple Relational Calculus q Safe Expressions q Queries q Domain Relational Calculus q Queries 2
  • 3. Ø Relational calculus is non-procedural. Ø In relational calculus, a query is solved by defining a solution relation in a single step. Ø Relational calculus is mainly based on the well-known propositional calculus, which is a method of calculating with sentences or declarations. Ø Various types of relational calculus are: ü Tuple Relational Calculus (TRC) ü Domain Relational Calculus (DRC) 3 Relational Calculus
  • 4. Ø A tuple variable is a variable that takes on tuples of a particular relation schema as values. Ø A tuple relational calculus query has the form: {T/ P(T)} Ø The result of this query is the set of all tuples t for which the formula P(T) evaluates to TRUE with T = t Sailors (sid, sname, rating, age) Query: Find all the sailors with a rating above 4 {S/S ∈ Sailors ∧ S.rating > 4} 4 Tuple Relational Calculus
  • 5. Ø Let Rel → be a relation name, R, S → be the tuple variables, a → an attribute of R, b → an attribute of S, op → operator in the set {<, ≤, >, ≥, =, ^=}. An Atomic formula is one of the following: ü R ∈ Rel ü R.a op S.b ü R.a op Constant or Constant op R.a Ø To represent the join and division of relational algebra by relational calculus, we need quantifiers such as: existential for join and universal for division. Ø A quantifier quantifies or indicates the quantity of something. Ø The existential quantifier (∃) states that at least one instance of a particular type of thing exist Similarly, the universal quantifier (∀) states that some condition applies to all or to every row of some type. Ø A formula is recursively defined by using the following rules: ü Any atomic formula ü If p and q are formulae, then ¬ p, p ∧ q, p ∨ q, or p ⇒ q are also formulae ü If p is a formula that contains T as a variable, then ∃ T(p) and ∀ T(p) are also formulae. 5 Tuple Relational Calculus
  • 6. Ø The quantifiers ∃ and ∀ are said to bind the tuple variable R; whereas a variable is said to be free in a formula if the formula does not contain an occurrence of a quantifier that binds it. Ø In most of the queries, the output is shown by using the free variables. Ø Safe Expressions: Whenever we use universal quantifiers or existential quantifiers in a calculus expression, we must make sure that the resulting expression makes sense. Ø A safe expression in relational calculus is one that is guaranteed to yield a finite number of tuples as its result; otherwise, the expression is called unsafe. Ø That means, an expression is said to be safe if all values in its result are from the domain of the expression. 6 Tuple Relational Calculus
  • 10. Ø In tuple relational calculus, the variables range over the tuples whereas in domain relational calculus, the variables range over the domains. Ø Let Rel → be a relation name, X, Y → be the domain variables, op → an operator in the set {<, ≤, >, ≥, =, ^=}. An Atomic formula in domain relational calculus is one of the following: ü <x1, x2, ... xn > ∈ Rel ü X op Y ü X op Constant or Constant op X Ø A formula is recursively defined by using the following rules: üAny atomic formula üIf p and q are formulae, then ¬p, p ∧ q, p ∨ q, or p ⇒ q are also formulae üIf p is a formula that contains X as a domain variable, then ∃X(p) and ∀ X(p) are also formulae Ø The quantifiers ∃ & ∀ are said to bind the domain variable X. Whereas a variable is said to be free in a formula if the formula does not contain an occurrence of a quantifier that binds it. 10 Domain Relational Calculus (DRC)
  • 13. 13