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 (20)

Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
data modeling and models
data modeling and modelsdata modeling and models
data modeling and models
 
Relational model
Relational modelRelational model
Relational model
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries Lecture
 
Transaction states and properties
Transaction states and propertiesTransaction states and properties
Transaction states and properties
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
DBMS: Types of keys
DBMS:  Types of keysDBMS:  Types of keys
DBMS: Types of keys
 
Deductive databases
Deductive databasesDeductive databases
Deductive databases
 
Chapter-7 Relational Calculus
Chapter-7 Relational CalculusChapter-7 Relational Calculus
Chapter-7 Relational Calculus
 
Acid properties
Acid propertiesAcid properties
Acid properties
 
Topological Sorting
Topological SortingTopological Sorting
Topological Sorting
 
Data Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptxData Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptx
 
ER-Model-ER Diagram
ER-Model-ER DiagramER-Model-ER Diagram
ER-Model-ER Diagram
 
Er model ppt
Er model pptEr model ppt
Er model ppt
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
1. Introduction to DBMS
1. Introduction to DBMS1. Introduction to DBMS
1. Introduction to DBMS
 
Basic concept of OOP's
Basic concept of OOP'sBasic concept of OOP's
Basic concept of OOP's
 

Similar to Dbms 14: Relational Calculus

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]DIwakar Rajput
 
Computational logic First Order Logic_part2
Computational logic First Order Logic_part2Computational logic First Order Logic_part2
Computational logic First Order Logic_part2banujahir1
 
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.pptxssuser92109d
 
leanCoR: lean Connection-based DL Reasoner
leanCoR: lean Connection-based DL ReasonerleanCoR: lean Connection-based DL Reasoner
leanCoR: lean Connection-based DL ReasonerAdriano Melo
 
Lecture-3-and-4.pdf
Lecture-3-and-4.pdfLecture-3-and-4.pdf
Lecture-3-and-4.pdfssuserc478ac
 
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 AnalysisMonica Franklin
 
Discrete structures &amp; optimization unit 1
Discrete structures &amp; optimization unit 1Discrete structures &amp; optimization unit 1
Discrete structures &amp; optimization unit 1SURBHI SAROHA
 
logicproof-141212042039-conversion-gate01.pdf
logicproof-141212042039-conversion-gate01.pdflogicproof-141212042039-conversion-gate01.pdf
logicproof-141212042039-conversion-gate01.pdfPradeeshSAI
 

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

Dbms 13: Query Using Relational Algebra
Dbms 13: Query Using Relational AlgebraDbms 13: Query Using Relational Algebra
Dbms 13: Query Using Relational AlgebraAmiya9439793168
 
Dbms 11: Relational Algebra
Dbms 11: Relational AlgebraDbms 11: Relational Algebra
Dbms 11: Relational AlgebraAmiya9439793168
 
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 ModelAmiya9439793168
 
Dbms 9: Relational Model
Dbms 9: Relational ModelDbms 9: Relational Model
Dbms 9: Relational ModelAmiya9439793168
 
Dbms 8: Enhanced ER Model
Dbms 8: Enhanced ER ModelDbms 8: Enhanced ER Model
Dbms 8: Enhanced ER ModelAmiya9439793168
 
Dbms 3: 3 Schema Architecture
Dbms 3: 3 Schema ArchitectureDbms 3: 3 Schema Architecture
Dbms 3: 3 Schema ArchitectureAmiya9439793168
 
Introduction to Database Management System
Introduction to Database Management SystemIntroduction to Database Management System
Introduction to Database Management SystemAmiya9439793168
 
Dbms 7: ER Diagram Design Issue
Dbms 7: ER Diagram Design IssueDbms 7: ER Diagram Design Issue
Dbms 7: ER Diagram Design IssueAmiya9439793168
 

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

An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxPurva Nikam
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 

Recently uploaded (20)

An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 

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