SlideShare a Scribd company logo
1 of 20
Download to read offline
CS501: DATABASE AND DATA
MINING
TRC and DRC
TUPLE RELATIONAL CALCULUS
 A nonprocedural query language, where eachp q y g g ,
query is of the form
{t | P (t ) }
 It is the set of all tuples t such that predicate P is
true for t
 t is a tuple variable, t [A ] denotes the value of tuple t
on attribute A
 t  r denotes that tuple t is in relation r
 P is a formula similar to that of the predicate P is a formula similar to that of the predicate
calculus
2
PREDICATE CALCULUS FORMULA
 Set of attributes and constants
 Set of comparison operators: (e.g., , , , , , )
 Set of connectives: and (), or (v)‚ not ()
 Implication (): x  y, if x is true, then y is true
x  y x v y
 Set of quantifiers:
 t r (Q (t ))  “there exists” a tuple in t in relation r
such that predicate Q (t ) is truep Q ( )
 t r (Q (t )) Q(t) is true “for all” tuples t in relation
r
3
BANK EXAMPLE
4
EXAMPLE QUERIES
 Find the loan number, branch name, and_ , _ ,
amount for loans of over Rs1200
 {t| t  loan  t[amount]> 1200}
Fi d h l b f h l f Find the loan number for each loan of an amount
greater than Rs1200
 {t |  s loan (t [loan_number ] = s [loan_number ] { | ( [ _ ] [ _ ]
s [amount ]  1200)}
 Find the names of all customers having a loan,
an account or both at the bankan account, or both at the bank
 {t | s  borrower ( t [customer_name ] = s
[customer_name ])
 d i ( [ ] u  depositor ( t [customer_name ] = u
[customer_name ])}
5
EXAMPLE QUERIES (2)
 Find the names of all customers who have a loan
and an account at the bank
 {t | s  borrower ( t [customer_name ] = s
[customer name ])[customer_name ])
 u  depositor ( t [customer_name ] = u
[customer_name] )}
Fi d th f ll t h i l t Find the names of all customers having a loan at
the Patliputra branch
 {t | s  borrower (t [customer_name ] = s{ ( [ ]
[customer_name ]
 u  loan (u [branch_name ] = “Patliputra”
 u [loan_number ] = s [loan_number ]))}
6
EXAMPLE QUERIES (3)
 Find the names of all customers who have a loan
at the Patliputra branch, but no account at any
branch of the bank
{t |  b (t [ t ] {t | s  borrower (t [customer_name ] = s
[customer_name ]
 u  loan (u [branch_name ] = “Patliputra”
 u [loan number ] = s [loan number ])) u [loan_number ] = s [loan_number ]))
 not v  depositor (v [customer_name ] =
t [customer_name ])}
7
EXAMPLE QUERIES (4)
 Find the names of all customers having a loang
from the Patliputra branch, and the cities in
which they live
{t |  l ( [b h ] “P tli t ” {t | s  loan (s [branch_name ] = “Patliputra”
 u  borrower (u [loan_number ] = s [loan_number ]
 t [customer_name ] = u [customer_name ]
  v  customer (u [customer name ] = v  v  customer (u [customer_name ] = v
[customer_name ]
 t [customer_city ] = v
[customer city ])))}[customer_city ])))}
8
EXAMPLE QUERIES (5)
 Find the names of all customers who have an
account at all branches located in branch_city =
“Dhanbad”:
{t |  b h ( [b h it ] “Dh b d”   {t |  u  branch (u [branch_city ] = “Dhanbad”   v
 account (v [branch_name] = u [branch_name ]  
w  depositor ( w[account_number ] = v
[account number ]  ( t [customer name ] = w[account_number ]  ( t [customer_name ] = w
[customer_name ])))}
9
SAFETY OF EXPRESSION
 It is possible to write tuple calculus expressionsp p p
that generate infinite set
 For example, { t |  t r } results in an infinite set if
the domain of any attribute of relation r is infinitethe domain of any attribute of relation r is infinite
 To guard against the problem, we restrict the set
of allowable expressions to safe expressions
10
SAFE EXPRESSION
 Let’s consider an expression {t | P (t )} in thep { | ( )}
tuple relational calculus
 dom(P): the set of all values referenced by P i.e., the
relations tuples or constants that appear in Prelations, tuples, or constants that appear in P
 The expression is said to be safe if every
component of t appears from the dom(P)
 E.g. { t |t  r| t [A] = 5  true } is not safe --- it
defines an infinite set with attribute values that do
not appear in any relation or tuples or constants in P.pp y p
11
DOMAIN RELATIONAL CALCULUS
 A nonprocedural query language equivalent inp q y g g q
power to the tuple relational calculus
 Each query is an expression of the form:
{  x1, x2, …, xn  | P (x1, x2, …, xn)}
 x1, x2, …, xn represent domain variables
 P represents a formula similar to that of the
predicate calculus
12
BANK EXAMPLE
13
EXAMPLE QUERIES
 Find the loan_number, branch_name, and
amount for loans of over Rs1200
 { l, b, a  |  l, b, a   loan  a > 1200}
 Find the names of all customers who have a loan Find the names of all customers who have a loan
of over Rs1200
 { c  |  l, b, a ( c, l   borrower   l, b, a 
loan a > 1200)} loan  a > 1200)}
 Find the names of all customers who have a loan
from the Patliputra branch and the loan amount:
 { c, a  |  l ( c, l   borrower  b ( l, b, a   loan 
b = “Patliputra”))}
 { c, a  |  l ( c, l   borrower   l, “ Patliputra”, a  { ( p
loan)} 14
EXAMPLE QUERIES (2)
 Find the names of all customers having a loan,g ,
an account, or both at the Patliputra branch:
 { c  |  l (  c, l   borrower
 b ( l b l b “P tli t ”))  b,a ( l, b, a   loan  b = “Patliputra”))
  a ( c, a   depositor  b,n ( a,
b, n   account  b = “Patliputra”))}
15
EXAMPLE QUERIES (3)
 Find the names of all customers who have an
account at all branches located in Dhanbad:
 { c  |  x,y,z ( x, y, z   branch  y = “Dhanbad”) 
 a b ( a x b   account   c a   depositor)} a,b ( a, x, b   account   c,a   depositor)}
16
SAFETY OF EXPRESSION
The expression:p
{  x1, x2, …, xn  | P (x1, x2, …, xn )}
is safe if -
all values that appear in tuples of the expression
are values from dom (P )are values from dom (P )
17
EXPRESSIVE POWER OF LANGUAGES
 The following languages are equivalentg g g q
 The basic relational algebra (without extended
relational algebra operation)
 The tuple relational calculus (restricted to safe The tuple relational calculus (restricted to safe
expression)
 The domain relational calculus (restricted to safe
i )expression)
18
RELATIONAL ALGEBRA TO TRC
 Let the following relation schemas be given:g g
 r<A,B,C>
 s<D,E,F>
Gi i i h l l i l Give an expression in the tuple relational
calculus that is equivalent to each of the
following:g
i. πA(r)
ii. σB=17(r)
iiiiii. r x s
iv. ΠA,F(σC=D(r x s))
19
RELATIONAL ALGEBRA TO DRC
 Let R=(A,B,C) and let r1 and r2 both be relations( , , ) 1 2
on schema R. Give an expression in the DRC that
is equivalent to each of the following:
i Π ( )i. ΠA(r1)
ii. σ B=17(r1)
iii. r1∩ r2
iv. r1 – r2
v. ΠA,B(r1) ΠB,C(r2)
20

More Related Content

What's hot

Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligencelordmwesh
 
2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinatesTarun Gehlot
 
Deep Reinforcement Learning
Deep Reinforcement LearningDeep Reinforcement Learning
Deep Reinforcement LearningUsman Qayyum
 
Lecture 9 Markov decision process
Lecture 9 Markov decision processLecture 9 Markov decision process
Lecture 9 Markov decision processVARUN KUMAR
 
Booth and bit pair encoding
Booth and bit pair encodingBooth and bit pair encoding
Booth and bit pair encodingBasit Ali
 
hands on machine learning Chapter 4 model training
hands on machine learning Chapter 4 model traininghands on machine learning Chapter 4 model training
hands on machine learning Chapter 4 model trainingJaey Jeong
 
Useful Techniques in Artificial Intelligence
Useful Techniques in Artificial IntelligenceUseful Techniques in Artificial Intelligence
Useful Techniques in Artificial IntelligenceIla Group
 
Goal based and utility based agents
Goal based and utility based agentsGoal based and utility based agents
Goal based and utility based agentsMegha Sharma
 
Unit3:Informed and Uninformed search
Unit3:Informed and Uninformed searchUnit3:Informed and Uninformed search
Unit3:Informed and Uninformed searchTekendra Nath Yogi
 
Adversarial search
Adversarial searchAdversarial search
Adversarial searchDheerendra k
 
Back tracking and branch and bound class 20
Back tracking and branch and bound class 20Back tracking and branch and bound class 20
Back tracking and branch and bound class 20Kumar
 
Artificial intelligence and knowledge representation
Artificial intelligence and knowledge representationArtificial intelligence and knowledge representation
Artificial intelligence and knowledge representationLikan Patra
 
Computational Complexity: Introduction-Turing Machines-Undecidability
Computational Complexity: Introduction-Turing Machines-UndecidabilityComputational Complexity: Introduction-Turing Machines-Undecidability
Computational Complexity: Introduction-Turing Machines-UndecidabilityAntonis Antonopoulos
 
ML_Unit_1_Part_C
ML_Unit_1_Part_CML_Unit_1_Part_C
ML_Unit_1_Part_CSrimatre K
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithmAnkit Garg
 
Designing your neural networks – a step by step walkthrough
Designing your neural networks – a step by step walkthroughDesigning your neural networks – a step by step walkthrough
Designing your neural networks – a step by step walkthroughLavanya Shukla
 
Cyrus beck line clipping algorithm
Cyrus beck line clipping algorithmCyrus beck line clipping algorithm
Cyrus beck line clipping algorithmPooja Dixit
 
Deep Learning Frameworks slides
Deep Learning Frameworks slides Deep Learning Frameworks slides
Deep Learning Frameworks slides Sheamus McGovern
 

What's hot (20)

Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligence
 
2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates
 
Deep Reinforcement Learning
Deep Reinforcement LearningDeep Reinforcement Learning
Deep Reinforcement Learning
 
Lecture 9 Markov decision process
Lecture 9 Markov decision processLecture 9 Markov decision process
Lecture 9 Markov decision process
 
Booth and bit pair encoding
Booth and bit pair encodingBooth and bit pair encoding
Booth and bit pair encoding
 
hands on machine learning Chapter 4 model training
hands on machine learning Chapter 4 model traininghands on machine learning Chapter 4 model training
hands on machine learning Chapter 4 model training
 
Useful Techniques in Artificial Intelligence
Useful Techniques in Artificial IntelligenceUseful Techniques in Artificial Intelligence
Useful Techniques in Artificial Intelligence
 
Goal based and utility based agents
Goal based and utility based agentsGoal based and utility based agents
Goal based and utility based agents
 
Unit3:Informed and Uninformed search
Unit3:Informed and Uninformed searchUnit3:Informed and Uninformed search
Unit3:Informed and Uninformed search
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
Back tracking and branch and bound class 20
Back tracking and branch and bound class 20Back tracking and branch and bound class 20
Back tracking and branch and bound class 20
 
Artificial intelligence and knowledge representation
Artificial intelligence and knowledge representationArtificial intelligence and knowledge representation
Artificial intelligence and knowledge representation
 
AI 5 | Local Search
AI 5 | Local SearchAI 5 | Local Search
AI 5 | Local Search
 
Computational Complexity: Introduction-Turing Machines-Undecidability
Computational Complexity: Introduction-Turing Machines-UndecidabilityComputational Complexity: Introduction-Turing Machines-Undecidability
Computational Complexity: Introduction-Turing Machines-Undecidability
 
ML_Unit_1_Part_C
ML_Unit_1_Part_CML_Unit_1_Part_C
ML_Unit_1_Part_C
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
 
Designing your neural networks – a step by step walkthrough
Designing your neural networks – a step by step walkthroughDesigning your neural networks – a step by step walkthrough
Designing your neural networks – a step by step walkthrough
 
Cyrus beck line clipping algorithm
Cyrus beck line clipping algorithmCyrus beck line clipping algorithm
Cyrus beck line clipping algorithm
 
Feedback Vertex Set
Feedback Vertex SetFeedback Vertex Set
Feedback Vertex Set
 
Deep Learning Frameworks slides
Deep Learning Frameworks slides Deep Learning Frameworks slides
Deep Learning Frameworks slides
 

Similar to Cs501 trc drc

Similar to Cs501 trc drc (20)

1643 y є r relational calculus-1
1643 y є r  relational calculus-11643 y є r  relational calculus-1
1643 y є r relational calculus-1
 
Ch5
Ch5Ch5
Ch5
 
Dbms module ii
Dbms module iiDbms module ii
Dbms module ii
 
ch5
ch5ch5
ch5
 
Cs501 rel algebra
Cs501 rel algebraCs501 rel algebra
Cs501 rel algebra
 
DBMS ppt (1).pptx
DBMS ppt (1).pptxDBMS ppt (1).pptx
DBMS ppt (1).pptx
 
Details of RDBMS.ppt
Details of RDBMS.pptDetails of RDBMS.ppt
Details of RDBMS.ppt
 
Lllll
LllllLllll
Lllll
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
 
3.ppt
3.ppt3.ppt
3.ppt
 
Database systems-Formal relational query languages
Database systems-Formal relational query languagesDatabase systems-Formal relational query languages
Database systems-Formal relational query languages
 
Relational algebra operations
Relational algebra operationsRelational algebra operations
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
 
Relation model part 1
Relation model part 1Relation model part 1
Relation model part 1
 
relational algebra
relational algebrarelational algebra
relational algebra
 
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
 
relational algebra Tuple Relational Calculus - database management system
relational algebra Tuple Relational Calculus - database management systemrelational algebra Tuple Relational Calculus - database management system
relational algebra Tuple Relational Calculus - database management system
 
ch6.ppt
ch6.pptch6.ppt
ch6.ppt
 
4. SQL in DBMS
4. SQL in DBMS4. SQL in DBMS
4. SQL in DBMS
 
Lec02
Lec02Lec02
Lec02
 

More from Kamal Singh Lodhi

More from Kamal Singh Lodhi (15)

Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure
 
Stack Algorithm
Stack AlgorithmStack Algorithm
Stack Algorithm
 
Data Structure (MC501)
Data Structure (MC501)Data Structure (MC501)
Data Structure (MC501)
 
Cs501 transaction
Cs501 transactionCs501 transaction
Cs501 transaction
 
Cs501 mining frequentpatterns
Cs501 mining frequentpatternsCs501 mining frequentpatterns
Cs501 mining frequentpatterns
 
Cs501 intro
Cs501 introCs501 intro
Cs501 intro
 
Cs501 fd nf
Cs501 fd nfCs501 fd nf
Cs501 fd nf
 
Cs501 dm intro
Cs501 dm introCs501 dm intro
Cs501 dm intro
 
Cs501 data preprocessingdw
Cs501 data preprocessingdwCs501 data preprocessingdw
Cs501 data preprocessingdw
 
Cs501 concurrency
Cs501 concurrencyCs501 concurrency
Cs501 concurrency
 
Cs501 cluster analysis
Cs501 cluster analysisCs501 cluster analysis
Cs501 cluster analysis
 
Cs501 classification prediction
Cs501 classification predictionCs501 classification prediction
Cs501 classification prediction
 
Attribute Classification
Attribute ClassificationAttribute Classification
Attribute Classification
 
Real Time ImageVideo Processing with Applications in Face Recognition
Real Time ImageVideo Processing with  Applications in Face Recognition   Real Time ImageVideo Processing with  Applications in Face Recognition
Real Time ImageVideo Processing with Applications in Face Recognition
 
Flow diagram
Flow diagramFlow diagram
Flow diagram
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 

Recently uploaded (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 

Cs501 trc drc

  • 1. CS501: DATABASE AND DATA MINING TRC and DRC
  • 2. TUPLE RELATIONAL CALCULUS  A nonprocedural query language, where eachp q y g g , query is of the form {t | P (t ) }  It is the set of all tuples t such that predicate P is true for t  t is a tuple variable, t [A ] denotes the value of tuple t on attribute A  t  r denotes that tuple t is in relation r  P is a formula similar to that of the predicate P is a formula similar to that of the predicate calculus 2
  • 3. PREDICATE CALCULUS FORMULA  Set of attributes and constants  Set of comparison operators: (e.g., , , , , , )  Set of connectives: and (), or (v)‚ not ()  Implication (): x  y, if x is true, then y is true x  y x v y  Set of quantifiers:  t r (Q (t ))  “there exists” a tuple in t in relation r such that predicate Q (t ) is truep Q ( )  t r (Q (t )) Q(t) is true “for all” tuples t in relation r 3
  • 5. EXAMPLE QUERIES  Find the loan number, branch name, and_ , _ , amount for loans of over Rs1200  {t| t  loan  t[amount]> 1200} Fi d h l b f h l f Find the loan number for each loan of an amount greater than Rs1200  {t |  s loan (t [loan_number ] = s [loan_number ] { | ( [ _ ] [ _ ] s [amount ]  1200)}  Find the names of all customers having a loan, an account or both at the bankan account, or both at the bank  {t | s  borrower ( t [customer_name ] = s [customer_name ])  d i ( [ ] u  depositor ( t [customer_name ] = u [customer_name ])} 5
  • 6. EXAMPLE QUERIES (2)  Find the names of all customers who have a loan and an account at the bank  {t | s  borrower ( t [customer_name ] = s [customer name ])[customer_name ])  u  depositor ( t [customer_name ] = u [customer_name] )} Fi d th f ll t h i l t Find the names of all customers having a loan at the Patliputra branch  {t | s  borrower (t [customer_name ] = s{ ( [ ] [customer_name ]  u  loan (u [branch_name ] = “Patliputra”  u [loan_number ] = s [loan_number ]))} 6
  • 7. EXAMPLE QUERIES (3)  Find the names of all customers who have a loan at the Patliputra branch, but no account at any branch of the bank {t |  b (t [ t ] {t | s  borrower (t [customer_name ] = s [customer_name ]  u  loan (u [branch_name ] = “Patliputra”  u [loan number ] = s [loan number ])) u [loan_number ] = s [loan_number ]))  not v  depositor (v [customer_name ] = t [customer_name ])} 7
  • 8. EXAMPLE QUERIES (4)  Find the names of all customers having a loang from the Patliputra branch, and the cities in which they live {t |  l ( [b h ] “P tli t ” {t | s  loan (s [branch_name ] = “Patliputra”  u  borrower (u [loan_number ] = s [loan_number ]  t [customer_name ] = u [customer_name ]   v  customer (u [customer name ] = v  v  customer (u [customer_name ] = v [customer_name ]  t [customer_city ] = v [customer city ])))}[customer_city ])))} 8
  • 9. EXAMPLE QUERIES (5)  Find the names of all customers who have an account at all branches located in branch_city = “Dhanbad”: {t |  b h ( [b h it ] “Dh b d”   {t |  u  branch (u [branch_city ] = “Dhanbad”   v  account (v [branch_name] = u [branch_name ]   w  depositor ( w[account_number ] = v [account number ]  ( t [customer name ] = w[account_number ]  ( t [customer_name ] = w [customer_name ])))} 9
  • 10. SAFETY OF EXPRESSION  It is possible to write tuple calculus expressionsp p p that generate infinite set  For example, { t |  t r } results in an infinite set if the domain of any attribute of relation r is infinitethe domain of any attribute of relation r is infinite  To guard against the problem, we restrict the set of allowable expressions to safe expressions 10
  • 11. SAFE EXPRESSION  Let’s consider an expression {t | P (t )} in thep { | ( )} tuple relational calculus  dom(P): the set of all values referenced by P i.e., the relations tuples or constants that appear in Prelations, tuples, or constants that appear in P  The expression is said to be safe if every component of t appears from the dom(P)  E.g. { t |t  r| t [A] = 5  true } is not safe --- it defines an infinite set with attribute values that do not appear in any relation or tuples or constants in P.pp y p 11
  • 12. DOMAIN RELATIONAL CALCULUS  A nonprocedural query language equivalent inp q y g g q power to the tuple relational calculus  Each query is an expression of the form: {  x1, x2, …, xn  | P (x1, x2, …, xn)}  x1, x2, …, xn represent domain variables  P represents a formula similar to that of the predicate calculus 12
  • 14. EXAMPLE QUERIES  Find the loan_number, branch_name, and amount for loans of over Rs1200  { l, b, a  |  l, b, a   loan  a > 1200}  Find the names of all customers who have a loan Find the names of all customers who have a loan of over Rs1200  { c  |  l, b, a ( c, l   borrower   l, b, a  loan a > 1200)} loan  a > 1200)}  Find the names of all customers who have a loan from the Patliputra branch and the loan amount:  { c, a  |  l ( c, l   borrower  b ( l, b, a   loan  b = “Patliputra”))}  { c, a  |  l ( c, l   borrower   l, “ Patliputra”, a  { ( p loan)} 14
  • 15. EXAMPLE QUERIES (2)  Find the names of all customers having a loan,g , an account, or both at the Patliputra branch:  { c  |  l (  c, l   borrower  b ( l b l b “P tli t ”))  b,a ( l, b, a   loan  b = “Patliputra”))   a ( c, a   depositor  b,n ( a, b, n   account  b = “Patliputra”))} 15
  • 16. EXAMPLE QUERIES (3)  Find the names of all customers who have an account at all branches located in Dhanbad:  { c  |  x,y,z ( x, y, z   branch  y = “Dhanbad”)   a b ( a x b   account   c a   depositor)} a,b ( a, x, b   account   c,a   depositor)} 16
  • 17. SAFETY OF EXPRESSION The expression:p {  x1, x2, …, xn  | P (x1, x2, …, xn )} is safe if - all values that appear in tuples of the expression are values from dom (P )are values from dom (P ) 17
  • 18. EXPRESSIVE POWER OF LANGUAGES  The following languages are equivalentg g g q  The basic relational algebra (without extended relational algebra operation)  The tuple relational calculus (restricted to safe The tuple relational calculus (restricted to safe expression)  The domain relational calculus (restricted to safe i )expression) 18
  • 19. RELATIONAL ALGEBRA TO TRC  Let the following relation schemas be given:g g  r<A,B,C>  s<D,E,F> Gi i i h l l i l Give an expression in the tuple relational calculus that is equivalent to each of the following:g i. πA(r) ii. σB=17(r) iiiiii. r x s iv. ΠA,F(σC=D(r x s)) 19
  • 20. RELATIONAL ALGEBRA TO DRC  Let R=(A,B,C) and let r1 and r2 both be relations( , , ) 1 2 on schema R. Give an expression in the DRC that is equivalent to each of the following: i Π ( )i. ΠA(r1) ii. σ B=17(r1) iii. r1∩ r2 iv. r1 – r2 v. ΠA,B(r1) ΠB,C(r2) 20