SlideShare a Scribd company logo
1 of 14
Download to read offline
Prof P Sreenivasa Kumar,
Department of CS&E, IITM.
1
Tuple Relational Calculus ( TRC )
Introduction
Procedural Query language
query specification involves giving a step by step process of
obtaining the query result
e.g., relational algebra
usage calls for detailed knowledge of the operators involved
difficult for the use of non-experts
Declarative Query language
query specification involves giving the logical conditions the
results are required to satisfy
easy for the use of non-experts
Prof P Sreenivasa Kumar,
Department of CS&E, IITM.
2
TRC – a declarative query language
Tuple variable – associated with a relation
( called the range relation )
• takes tuples from the range relation as its values
• t: tuple variable over relation r with scheme R(A,B,C )
t.A stands for value of column A etc
TRC Query – basic form:
{ t1.Ai1
, t2.Ai2
,…tm.Aim
| θ }
predicate calculus expression
involving tuple variables
t1, t2,…, tm, tm+1,…,ts
- specifies the condition to be satisfied
Prof P Sreenivasa Kumar,
Department of CS&E, IITM.
3
An example TRC query
student (rollNo, name, degree, year, sex, deptNo, advisor )
department (deptId, name, hod, phone )
Obtain the rollNo, name of all girl students
in the Maths Dept (deptId = 2)
{s.rollNo,s.name| student(s)^ s.sex=‘F’^ s.deptNo=2}
attributes
required in
the result
This predicate is true whenever
value of s is a tuple from the
student relation, false otherwise
In general, if t is a tuple variable with range
relation r, r( t ) is taken as a predicate which
is true if and only if the value of t is a tuple in r
Prof P Sreenivasa Kumar,
Department of CS&E, IITM.
4
Atomic expressions are the following:
1. r ( t ) -- true if t is a tuple in the relation instance r
2. t1. Ai <compOp> t2 .Aj compOp is one of {<, ≤ , >, ≥, =, ≠ }
3. t.Ai <compOp> c c is a constant of appropriate type
Composite expressions:
1. Any atomic expression
2. F1 ∧ F2 ,, F1 ∨ F2 , ¬ F1 where F1 and F2 are expressions
3. (∀t) (F), (∃t) (F) where F is an expression
and t is a tuple variable
Free Variables
Bound Variables – quantified variables
General form of the condition in TRC queries
Prof P Sreenivasa Kumar,
Department of CS&E, IITM.
5
All possible tuple assignments to the free variables in the query are
considered.
For any specific assignment,
if the expression to the right of the vertical bar evaluates to true,
that combination of tuple values
would be used to produce a tuple in the result relation.
While producing the result tuple, the values of the attributes for the
corresponding tuple variables as specified on the left side of the
vertical bar would be used.
Note: The only free variables are the ones that appear to the left
of the vertical bar
Interpretation of the query in TRC
Prof P Sreenivasa Kumar,
Department of CS&E, IITM.
6
Obtain the rollNo, name of all girl students in the
Maths Dept
{s.rollNo,s.name | student(s) ^ s.sex=‘F’ ^
(∃ d)(department(d) ^ d.name=‘Maths’
^ d.deptId = s.deptNo)}
s: free tuple variable d: existentially bound tuple variable
Existentially or universally quantified tuple variables can be used
on the RHS of the vertical bar to specify query conditions
Attributes of free (or unbound ) tuple variables can be used on LHS
of vertical bar to specify attributes required in the results
Example TRC queries
Prof P Sreenivasa Kumar,
Department of CS&E, IITM.
7
Example Relational Scheme
student (rollNo, name, degree, year, sex, deptNo, advisor)
department (deptId, name, hod, phone)
professor (empId, name, sex, startYear, deptNo, phone)
course (courseId, cname, credits, deptNo)
enrollment (rollNo, courseId, sem, year, grade)
teaching (empId, courseId, sem, year, classRoom)
preRequisite (preReqCourse, courseID)
Q2
Q3
Q4
Q5
Prof P Sreenivasa Kumar,
Department of CS&E, IITM.
8
Example queries in TRC (1/5)
1)Determine the departments that do not have
any girl students
student (rollNo, name, degree, year, sex, deptNo, advisor)
department (deptId, name, hod, phone)
{d.name|department(d) ^
¬(∃ s)(student(s) ^
s.sex =‘F’ ^ s.deptNo = d.deptId)
Prof P Sreenivasa Kumar,
Department of CS&E, IITM.
9
2)Obtain the names of courses enrolled by student
named Mahesh
{c.name | course(c) ^
(∃s) (∃e) ( student(s) ^ enrollment(e)
^ s.name = “Mahesh”
^ s.rollNo = e.rollNo
^ c.courseId = e.courseId }
Examples queries in TRC (2/5) Schema
Prof P Sreenivasa Kumar,
Department of CS&E, IITM.
10
3)Get the names of students who have scored ‘S’ in all
subjects they have enrolled. Assume that every
student is enrolled in at least one course.
{s.name | student(s) ^
(∀e)(( enrollment(e) ^
e.rollNo = s.rollNo) → e.grade =‘S’)}
person P with all S grades:
for enrollment tuples not having her roll number, LHS is false
for enrollment tuples having her roll number, LHS is true, RHS also true
so the implication is true for all e tuples
person Q with some non-S grades:
for enrollment tuples not having her roll number, LHS is false
for enrollment tuples having her roll number, LHS is true, but RHS is false for
at least one tuple.
So the implication is not true for at least one tuple.
Examples queries in TRC (3/5) Schema
Prof P Sreenivasa Kumar,
Department of CS&E, IITM.
11
4) Get the names of students who have taken at least
one course taught by their advisor
{s.name | student(s) ^
(∃e)(∃t)(enrollment(e) ^ teaching(t) ^
e.courseId = t.courseId ^
e.rollNo = s.rollNo ^
t.empId = s.advisor}
5) Display the departments whose HODs are teaching
at least one course in the current semester
{d.name | department(d) ^(∃t)(teaching(t) ^
t.empid = d.hod
^ t.sem = ‘odd’ ^ t.year = ‘2008’)}
Examples queries in TRC (4/5) Schema
Prof P Sreenivasa Kumar,
Department of CS&E, IITM.
12
6)Determine the students who are enrolled for every
course taught by Prof Ramanujam. Assume that Prof
Ramanujam teaches at least one course.
1. {s.rollNo | student (s) ^
2. (∀c)(course (c) ^
3. ((∃t),(∃p)( teaching(t) ^ professor(p) ^
4. t.courseId = c.courseId ^
5. p.name = “Ramanujam” ^
6. p.empId = t.empId )) →
7. (∃e) (enrollment(e) ^
8. e.courseId = c.courseId ^
9. e.rollNo = s.rollNo)
10. )
11. }
Examples queries in TRC (5/5) Schema
Prof P Sreenivasa Kumar,
Department of CS&E, IITM.
13
What is the result of the query:
{s.rollNo | ¬ student(s)} ?
Infinite answers !!
Unsafe TRC expression :
Any expression whose result uses “constants / values” that do not
appear in the instances of any of the database relations.
Unsafe expressions are to be avoided while specifying TRC queries.
Problem with unrestricted use of Negation
Prof P Sreenivasa Kumar,
Department of CS&E, IITM.
14
It can be shown that
both Tuple Relational Calculus and Relational Algebra
have the same expressive power
A query can be formulated in (safe) TRC
if and only if it can be formulated in RA
Both can not be used to formulate queries involving
transitive closure
-- find all direct or indirect pre-requisites of a course
-- find all subordinates of a specific employee etc.
Expressive power of TRC and Relational Algebra

More Related Content

What's hot

Dbms relational model
Dbms relational modelDbms relational model
Dbms relational modelChirag vasava
 
Sql grant, revoke, privileges and roles
Sql grant, revoke, privileges and rolesSql grant, revoke, privileges and roles
Sql grant, revoke, privileges and rolesVivek Singh
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraintsmadhav bansal
 
DDL And DML
DDL And DMLDDL And DML
DDL And DMLpnp @in
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship DiagramShakila Mahjabin
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introductionSmriti Jain
 
1. Introduction to DBMS
1. Introduction to DBMS1. Introduction to DBMS
1. Introduction to DBMSkoolkampus
 
DBMS Integrity rule
DBMS Integrity ruleDBMS Integrity rule
DBMS Integrity ruleGirdharRatne
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model IntroductionNishant Munjal
 
Integrity constraints in dbms
Integrity constraints in dbmsIntegrity constraints in dbms
Integrity constraints in dbmsVignesh Saravanan
 
Dbms 14: Relational Calculus
Dbms 14: Relational CalculusDbms 14: Relational Calculus
Dbms 14: Relational CalculusAmiya9439793168
 
Multivalued dependency
Multivalued dependencyMultivalued dependency
Multivalued dependencyavniS
 

What's hot (20)

DATABASE CONSTRAINTS
DATABASE CONSTRAINTSDATABASE CONSTRAINTS
DATABASE CONSTRAINTS
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
Relational algebra in dbms
Relational algebra in dbmsRelational algebra in dbms
Relational algebra in dbms
 
Sql grant, revoke, privileges and roles
Sql grant, revoke, privileges and rolesSql grant, revoke, privileges and roles
Sql grant, revoke, privileges and roles
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
DDL And DML
DDL And DMLDDL And DML
DDL And DML
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
1. Introduction to DBMS
1. Introduction to DBMS1. Introduction to DBMS
1. Introduction to DBMS
 
DBMS Integrity rule
DBMS Integrity ruleDBMS Integrity rule
DBMS Integrity rule
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
Integrity constraints in dbms
Integrity constraints in dbmsIntegrity constraints in dbms
Integrity constraints in dbms
 
View of data DBMS
View of data DBMSView of data DBMS
View of data DBMS
 
Dbms 14: Relational Calculus
Dbms 14: Relational CalculusDbms 14: Relational Calculus
Dbms 14: Relational Calculus
 
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
 
Multivalued dependency
Multivalued dependencyMultivalued dependency
Multivalued dependency
 
DBMS Notes: DDL DML DCL
DBMS Notes: DDL DML DCLDBMS Notes: DDL DML DCL
DBMS Notes: DDL DML DCL
 
ER MODEL
ER MODELER MODEL
ER MODEL
 
Files Vs DataBase
Files Vs DataBaseFiles Vs DataBase
Files Vs DataBase
 

Similar to 3.1 tuple relational_calculus

Database systems-Formal relational query languages
Database systems-Formal relational query languagesDatabase systems-Formal relational query languages
Database systems-Formal relational query languagesjamunaashok
 
3 relational model
3 relational model3 relational model
3 relational modelUtkarsh De
 
Master’s theorem Derivative Analysis
Master’s theorem Derivative AnalysisMaster’s theorem Derivative Analysis
Master’s theorem Derivative AnalysisIRJET Journal
 
Fractional Derivatives of Some Fractional Functions and Their Applications
Fractional Derivatives of Some Fractional Functions and Their ApplicationsFractional Derivatives of Some Fractional Functions and Their Applications
Fractional Derivatives of Some Fractional Functions and Their ApplicationsAssociate Professor in VSB Coimbatore
 
Infinite sequence & series 1st lecture
Infinite sequence & series 1st lecture Infinite sequence & series 1st lecture
Infinite sequence & series 1st lecture Mohsin Ramay
 
ON M(M,m)/M/C/N: Interdependent Queueing Model
ON M(M,m)/M/C/N: Interdependent Queueing ModelON M(M,m)/M/C/N: Interdependent Queueing Model
ON M(M,m)/M/C/N: Interdependent Queueing ModelIOSR Journals
 
4 the sql_standard
4 the  sql_standard4 the  sql_standard
4 the sql_standardUtkarsh De
 
Ail apresentation(kumazawa)
Ail apresentation(kumazawa)Ail apresentation(kumazawa)
Ail apresentation(kumazawa)TakaKumazawa
 
A Mathematical Model to Solve Nonlinear Initial and Boundary Value Problems b...
A Mathematical Model to Solve Nonlinear Initial and Boundary Value Problems b...A Mathematical Model to Solve Nonlinear Initial and Boundary Value Problems b...
A Mathematical Model to Solve Nonlinear Initial and Boundary Value Problems b...IJERA Editor
 
presentation at E-Learn 2008
presentation at E-Learn 2008presentation at E-Learn 2008
presentation at E-Learn 2008Dr. Popat Tambade
 
13 sequences and series
13   sequences and series13   sequences and series
13 sequences and seriesKathManarang
 
Time Table Scheduling Problem Using Fuzzy Algorithmic Approach
Time Table Scheduling Problem Using Fuzzy Algorithmic ApproachTime Table Scheduling Problem Using Fuzzy Algorithmic Approach
Time Table Scheduling Problem Using Fuzzy Algorithmic ApproachWaqas Tariq
 
Solution of Ordinary Differential Equation with Initial Condition Using New E...
Solution of Ordinary Differential Equation with Initial Condition Using New E...Solution of Ordinary Differential Equation with Initial Condition Using New E...
Solution of Ordinary Differential Equation with Initial Condition Using New E...IRJET Journal
 
Module 2_Relational Algebra.pptx
Module 2_Relational Algebra.pptxModule 2_Relational Algebra.pptx
Module 2_Relational Algebra.pptxShashiKumarB5
 
Hydraulic similitude and model analysis
Hydraulic similitude and model analysisHydraulic similitude and model analysis
Hydraulic similitude and model analysisMohsin Siddique
 
Adaptive relevance feedback in information retrieval
Adaptive relevance feedback in information retrievalAdaptive relevance feedback in information retrieval
Adaptive relevance feedback in information retrievalYI-JHEN LIN
 
A genetic algorithm for a university weekly courses timetabling problem
A genetic algorithm for a university weekly courses timetabling problemA genetic algorithm for a university weekly courses timetabling problem
A genetic algorithm for a university weekly courses timetabling problemMotasem Smadi
 

Similar to 3.1 tuple relational_calculus (20)

Trc final
Trc finalTrc final
Trc final
 
3_Relational_Model.pdf
3_Relational_Model.pdf3_Relational_Model.pdf
3_Relational_Model.pdf
 
Database systems-Formal relational query languages
Database systems-Formal relational query languagesDatabase systems-Formal relational query languages
Database systems-Formal relational query languages
 
3 relational model
3 relational model3 relational model
3 relational model
 
Master’s theorem Derivative Analysis
Master’s theorem Derivative AnalysisMaster’s theorem Derivative Analysis
Master’s theorem Derivative Analysis
 
Fractional Derivatives of Some Fractional Functions and Their Applications
Fractional Derivatives of Some Fractional Functions and Their ApplicationsFractional Derivatives of Some Fractional Functions and Their Applications
Fractional Derivatives of Some Fractional Functions and Their Applications
 
Infinite sequence & series 1st lecture
Infinite sequence & series 1st lecture Infinite sequence & series 1st lecture
Infinite sequence & series 1st lecture
 
ON M(M,m)/M/C/N: Interdependent Queueing Model
ON M(M,m)/M/C/N: Interdependent Queueing ModelON M(M,m)/M/C/N: Interdependent Queueing Model
ON M(M,m)/M/C/N: Interdependent Queueing Model
 
4 the sql_standard
4 the  sql_standard4 the  sql_standard
4 the sql_standard
 
Ail apresentation(kumazawa)
Ail apresentation(kumazawa)Ail apresentation(kumazawa)
Ail apresentation(kumazawa)
 
A Mathematical Model to Solve Nonlinear Initial and Boundary Value Problems b...
A Mathematical Model to Solve Nonlinear Initial and Boundary Value Problems b...A Mathematical Model to Solve Nonlinear Initial and Boundary Value Problems b...
A Mathematical Model to Solve Nonlinear Initial and Boundary Value Problems b...
 
presentation at E-Learn 2008
presentation at E-Learn 2008presentation at E-Learn 2008
presentation at E-Learn 2008
 
A Polynomial-Space Exact Algorithm for TSP in Degree-5 Graphs
A Polynomial-Space Exact Algorithm for TSP in Degree-5 GraphsA Polynomial-Space Exact Algorithm for TSP in Degree-5 Graphs
A Polynomial-Space Exact Algorithm for TSP in Degree-5 Graphs
 
13 sequences and series
13   sequences and series13   sequences and series
13 sequences and series
 
Time Table Scheduling Problem Using Fuzzy Algorithmic Approach
Time Table Scheduling Problem Using Fuzzy Algorithmic ApproachTime Table Scheduling Problem Using Fuzzy Algorithmic Approach
Time Table Scheduling Problem Using Fuzzy Algorithmic Approach
 
Solution of Ordinary Differential Equation with Initial Condition Using New E...
Solution of Ordinary Differential Equation with Initial Condition Using New E...Solution of Ordinary Differential Equation with Initial Condition Using New E...
Solution of Ordinary Differential Equation with Initial Condition Using New E...
 
Module 2_Relational Algebra.pptx
Module 2_Relational Algebra.pptxModule 2_Relational Algebra.pptx
Module 2_Relational Algebra.pptx
 
Hydraulic similitude and model analysis
Hydraulic similitude and model analysisHydraulic similitude and model analysis
Hydraulic similitude and model analysis
 
Adaptive relevance feedback in information retrieval
Adaptive relevance feedback in information retrievalAdaptive relevance feedback in information retrieval
Adaptive relevance feedback in information retrieval
 
A genetic algorithm for a university weekly courses timetabling problem
A genetic algorithm for a university weekly courses timetabling problemA genetic algorithm for a university weekly courses timetabling problem
A genetic algorithm for a university weekly courses timetabling problem
 

More from Utkarsh De

4 k Display Technology
4 k Display Technology4 k Display Technology
4 k Display TechnologyUtkarsh De
 
6 relational schema_design
6 relational schema_design6 relational schema_design
6 relational schema_designUtkarsh De
 
5 data storage_and_indexing
5 data storage_and_indexing5 data storage_and_indexing
5 data storage_and_indexingUtkarsh De
 
2 entity relationship_model
2 entity relationship_model2 entity relationship_model
2 entity relationship_modelUtkarsh De
 
1 introduction
1 introduction1 introduction
1 introductionUtkarsh De
 
Four way traffic light conrol using Verilog
Four way traffic light conrol using VerilogFour way traffic light conrol using Verilog
Four way traffic light conrol using VerilogUtkarsh De
 

More from Utkarsh De (6)

4 k Display Technology
4 k Display Technology4 k Display Technology
4 k Display Technology
 
6 relational schema_design
6 relational schema_design6 relational schema_design
6 relational schema_design
 
5 data storage_and_indexing
5 data storage_and_indexing5 data storage_and_indexing
5 data storage_and_indexing
 
2 entity relationship_model
2 entity relationship_model2 entity relationship_model
2 entity relationship_model
 
1 introduction
1 introduction1 introduction
1 introduction
 
Four way traffic light conrol using Verilog
Four way traffic light conrol using VerilogFour way traffic light conrol using Verilog
Four way traffic light conrol using Verilog
 

Recently uploaded

VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
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
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
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
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 

Recently uploaded (20)

VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.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
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
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
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
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
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
🔝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...
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 

3.1 tuple relational_calculus

  • 1. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 1 Tuple Relational Calculus ( TRC ) Introduction Procedural Query language query specification involves giving a step by step process of obtaining the query result e.g., relational algebra usage calls for detailed knowledge of the operators involved difficult for the use of non-experts Declarative Query language query specification involves giving the logical conditions the results are required to satisfy easy for the use of non-experts
  • 2. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 2 TRC – a declarative query language Tuple variable – associated with a relation ( called the range relation ) • takes tuples from the range relation as its values • t: tuple variable over relation r with scheme R(A,B,C ) t.A stands for value of column A etc TRC Query – basic form: { t1.Ai1 , t2.Ai2 ,…tm.Aim | θ } predicate calculus expression involving tuple variables t1, t2,…, tm, tm+1,…,ts - specifies the condition to be satisfied
  • 3. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 3 An example TRC query student (rollNo, name, degree, year, sex, deptNo, advisor ) department (deptId, name, hod, phone ) Obtain the rollNo, name of all girl students in the Maths Dept (deptId = 2) {s.rollNo,s.name| student(s)^ s.sex=‘F’^ s.deptNo=2} attributes required in the result This predicate is true whenever value of s is a tuple from the student relation, false otherwise In general, if t is a tuple variable with range relation r, r( t ) is taken as a predicate which is true if and only if the value of t is a tuple in r
  • 4. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 4 Atomic expressions are the following: 1. r ( t ) -- true if t is a tuple in the relation instance r 2. t1. Ai <compOp> t2 .Aj compOp is one of {<, ≤ , >, ≥, =, ≠ } 3. t.Ai <compOp> c c is a constant of appropriate type Composite expressions: 1. Any atomic expression 2. F1 ∧ F2 ,, F1 ∨ F2 , ¬ F1 where F1 and F2 are expressions 3. (∀t) (F), (∃t) (F) where F is an expression and t is a tuple variable Free Variables Bound Variables – quantified variables General form of the condition in TRC queries
  • 5. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 5 All possible tuple assignments to the free variables in the query are considered. For any specific assignment, if the expression to the right of the vertical bar evaluates to true, that combination of tuple values would be used to produce a tuple in the result relation. While producing the result tuple, the values of the attributes for the corresponding tuple variables as specified on the left side of the vertical bar would be used. Note: The only free variables are the ones that appear to the left of the vertical bar Interpretation of the query in TRC
  • 6. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 6 Obtain the rollNo, name of all girl students in the Maths Dept {s.rollNo,s.name | student(s) ^ s.sex=‘F’ ^ (∃ d)(department(d) ^ d.name=‘Maths’ ^ d.deptId = s.deptNo)} s: free tuple variable d: existentially bound tuple variable Existentially or universally quantified tuple variables can be used on the RHS of the vertical bar to specify query conditions Attributes of free (or unbound ) tuple variables can be used on LHS of vertical bar to specify attributes required in the results Example TRC queries
  • 7. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 7 Example Relational Scheme student (rollNo, name, degree, year, sex, deptNo, advisor) department (deptId, name, hod, phone) professor (empId, name, sex, startYear, deptNo, phone) course (courseId, cname, credits, deptNo) enrollment (rollNo, courseId, sem, year, grade) teaching (empId, courseId, sem, year, classRoom) preRequisite (preReqCourse, courseID) Q2 Q3 Q4 Q5
  • 8. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 8 Example queries in TRC (1/5) 1)Determine the departments that do not have any girl students student (rollNo, name, degree, year, sex, deptNo, advisor) department (deptId, name, hod, phone) {d.name|department(d) ^ ¬(∃ s)(student(s) ^ s.sex =‘F’ ^ s.deptNo = d.deptId)
  • 9. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 9 2)Obtain the names of courses enrolled by student named Mahesh {c.name | course(c) ^ (∃s) (∃e) ( student(s) ^ enrollment(e) ^ s.name = “Mahesh” ^ s.rollNo = e.rollNo ^ c.courseId = e.courseId } Examples queries in TRC (2/5) Schema
  • 10. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 10 3)Get the names of students who have scored ‘S’ in all subjects they have enrolled. Assume that every student is enrolled in at least one course. {s.name | student(s) ^ (∀e)(( enrollment(e) ^ e.rollNo = s.rollNo) → e.grade =‘S’)} person P with all S grades: for enrollment tuples not having her roll number, LHS is false for enrollment tuples having her roll number, LHS is true, RHS also true so the implication is true for all e tuples person Q with some non-S grades: for enrollment tuples not having her roll number, LHS is false for enrollment tuples having her roll number, LHS is true, but RHS is false for at least one tuple. So the implication is not true for at least one tuple. Examples queries in TRC (3/5) Schema
  • 11. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 11 4) Get the names of students who have taken at least one course taught by their advisor {s.name | student(s) ^ (∃e)(∃t)(enrollment(e) ^ teaching(t) ^ e.courseId = t.courseId ^ e.rollNo = s.rollNo ^ t.empId = s.advisor} 5) Display the departments whose HODs are teaching at least one course in the current semester {d.name | department(d) ^(∃t)(teaching(t) ^ t.empid = d.hod ^ t.sem = ‘odd’ ^ t.year = ‘2008’)} Examples queries in TRC (4/5) Schema
  • 12. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 12 6)Determine the students who are enrolled for every course taught by Prof Ramanujam. Assume that Prof Ramanujam teaches at least one course. 1. {s.rollNo | student (s) ^ 2. (∀c)(course (c) ^ 3. ((∃t),(∃p)( teaching(t) ^ professor(p) ^ 4. t.courseId = c.courseId ^ 5. p.name = “Ramanujam” ^ 6. p.empId = t.empId )) → 7. (∃e) (enrollment(e) ^ 8. e.courseId = c.courseId ^ 9. e.rollNo = s.rollNo) 10. ) 11. } Examples queries in TRC (5/5) Schema
  • 13. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 13 What is the result of the query: {s.rollNo | ¬ student(s)} ? Infinite answers !! Unsafe TRC expression : Any expression whose result uses “constants / values” that do not appear in the instances of any of the database relations. Unsafe expressions are to be avoided while specifying TRC queries. Problem with unrestricted use of Negation
  • 14. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 14 It can be shown that both Tuple Relational Calculus and Relational Algebra have the same expressive power A query can be formulated in (safe) TRC if and only if it can be formulated in RA Both can not be used to formulate queries involving transitive closure -- find all direct or indirect pre-requisites of a course -- find all subordinates of a specific employee etc. Expressive power of TRC and Relational Algebra