SlideShare a Scribd company logo
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

Security in ORACLE RDBMS
Security in ORACLE RDBMSSecurity in ORACLE RDBMS
Security in ORACLE RDBMS
Manohar Tatwawadi
 
Uml
UmlUml
Dbms ii mca-ch3-er-model-2013
Dbms ii mca-ch3-er-model-2013Dbms ii mca-ch3-er-model-2013
Dbms ii mca-ch3-er-model-2013
Prosanta Ghosh
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
Forrester High School
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
Nishant Munjal
 
Software Engineering Lab Manual
Software Engineering Lab ManualSoftware Engineering Lab Manual
Software Engineering Lab Manual
Neelamani Samal
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
VARSHAKUMARI49
 
Enhanced E-R diagram
Enhanced E-R diagramEnhanced E-R diagram
Enhanced E-R diagram
Mayank Jain
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
kalyanineve
 
Arrays
ArraysArrays
Relational algebra in DBMS
Relational algebra in DBMSRelational algebra in DBMS
Relational algebra in DBMS
Arafat Hossan
 
dbms lab manual
dbms lab manualdbms lab manual
dbms lab manual
stalinjothi
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
Rakhi Mukherji
 
Sql
SqlSql
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization Techniques
Nishant Munjal
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
TechandMate
 
The Relational Model
The Relational ModelThe Relational Model
The Relational Model
Bhandari Nawaraj
 
Basic SQL
Basic SQLBasic SQL
Basic SQL
Durgesh Tripathi
 
File organisation
File organisationFile organisation
File organisation
Samuel Igbanogu
 
Hibernate Tutorial
Hibernate TutorialHibernate Tutorial
Hibernate Tutorial
Ram132
 

What's hot (20)

Security in ORACLE RDBMS
Security in ORACLE RDBMSSecurity in ORACLE RDBMS
Security in ORACLE RDBMS
 
Uml
UmlUml
Uml
 
Dbms ii mca-ch3-er-model-2013
Dbms ii mca-ch3-er-model-2013Dbms ii mca-ch3-er-model-2013
Dbms ii mca-ch3-er-model-2013
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
Software Engineering Lab Manual
Software Engineering Lab ManualSoftware Engineering Lab Manual
Software Engineering Lab Manual
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
Enhanced E-R diagram
Enhanced E-R diagramEnhanced E-R diagram
Enhanced E-R diagram
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
 
Arrays
ArraysArrays
Arrays
 
Relational algebra in DBMS
Relational algebra in DBMSRelational algebra in DBMS
Relational algebra in DBMS
 
dbms lab manual
dbms lab manualdbms lab manual
dbms lab manual
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Sql
SqlSql
Sql
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization Techniques
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
 
The Relational Model
The Relational ModelThe Relational Model
The Relational Model
 
Basic SQL
Basic SQLBasic SQL
Basic SQL
 
File organisation
File organisationFile organisation
File organisation
 
Hibernate Tutorial
Hibernate TutorialHibernate Tutorial
Hibernate Tutorial
 

Similar to Cs501 trc drc

1643 y є r relational calculus-1
1643 y є r  relational calculus-11643 y є r  relational calculus-1
1643 y є r relational calculus-1
Dr Fereidoun Dejahang
 
Ch5
Ch5Ch5
Dbms module ii
Dbms module iiDbms module ii
Dbms module ii
SANTOSH RATH
 
ch5
ch5ch5
Cs501 rel algebra
Cs501 rel algebraCs501 rel algebra
Cs501 rel algebra
Kamal Singh Lodhi
 
DBMS ppt (1).pptx
DBMS ppt (1).pptxDBMS ppt (1).pptx
DBMS ppt (1).pptx
spresentskava
 
Details of RDBMS.ppt
Details of RDBMS.pptDetails of RDBMS.ppt
Details of RDBMS.ppt
ShivareddyGangam
 
Lllll
LllllLllll
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
koolkampus
 
3.ppt
3.ppt3.ppt
Database systems-Formal relational query languages
Database systems-Formal relational query languagesDatabase systems-Formal relational query languages
Database systems-Formal relational query languages
jamunaashok
 
Relational algebra operations
Relational algebra operationsRelational algebra operations
Relational algebra operations
SanthiNivas
 
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
Shashi Patel
 
Relation model part 1
Relation model part 1Relation model part 1
Relation model part 1
Siti Ismail
 
relational algebra
relational algebrarelational algebra
relational algebra
Shashank Singh
 
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
Roshni814224
 
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
Surya Swaroop
 
ch6.ppt
ch6.pptch6.ppt
ch6.ppt
Shobi29
 
4. SQL in DBMS
4. SQL in DBMS4. SQL in DBMS
4. SQL in DBMS
koolkampus
 
Lec02
Lec02Lec02

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

Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure
Kamal Singh Lodhi
 
Stack Algorithm
Stack AlgorithmStack Algorithm
Stack Algorithm
Kamal Singh Lodhi
 
Data Structure (MC501)
Data Structure (MC501)Data Structure (MC501)
Data Structure (MC501)
Kamal Singh Lodhi
 
Cs501 transaction
Cs501 transactionCs501 transaction
Cs501 transaction
Kamal Singh Lodhi
 
Cs501 mining frequentpatterns
Cs501 mining frequentpatternsCs501 mining frequentpatterns
Cs501 mining frequentpatterns
Kamal Singh Lodhi
 
Cs501 intro
Cs501 introCs501 intro
Cs501 intro
Kamal Singh Lodhi
 
Cs501 fd nf
Cs501 fd nfCs501 fd nf
Cs501 fd nf
Kamal Singh Lodhi
 
Cs501 dm intro
Cs501 dm introCs501 dm intro
Cs501 dm intro
Kamal Singh Lodhi
 
Cs501 data preprocessingdw
Cs501 data preprocessingdwCs501 data preprocessingdw
Cs501 data preprocessingdw
Kamal Singh Lodhi
 
Cs501 concurrency
Cs501 concurrencyCs501 concurrency
Cs501 concurrency
Kamal Singh Lodhi
 
Cs501 cluster analysis
Cs501 cluster analysisCs501 cluster analysis
Cs501 cluster analysis
Kamal Singh Lodhi
 
Cs501 classification prediction
Cs501 classification predictionCs501 classification prediction
Cs501 classification prediction
Kamal Singh Lodhi
 
Attribute Classification
Attribute ClassificationAttribute Classification
Attribute Classification
Kamal Singh Lodhi
 
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
Kamal Singh Lodhi
 
Flow diagram
Flow diagramFlow diagram
Flow diagram
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

Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 

Recently uploaded (20)

Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 

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