SlideShare a Scribd company logo
1 of 30
Admission in India 2015 
By: 
admission.edhole.com
Relational Calculus 
CS 186, Spring 2007, Lecture 
6 
R&G, Chapter 4 
$ 
Mary Roth " 
We will occasionally use this 
arrow notation unless there 
is danger of no confusion. 
Ronald Graham 
Elements of Ramsey Theory 
admission.edhole.com
Administrivia 
• Homework 1 due in 1 week 
– Thursday, Feb 8 10 p.m. 
• New syllabus on web site 
• Questions? 
admission.edhole.com
Review 
• Database Systems have both theory and practice 
• It’s a systems course, so we are heavy on the 
practice 
• But our practice has to have theory to back it up 8-) 
• …so we will be looking at both of them in parallel 
admission.edhole.com
Review: Where have we been? 
Theory Practice 
Query Optimization 
and Execution 
Relational Operators 
Files and Access Methods 
Buffer Management 
Disk Space Management 
DB 
Lecture 2 
Relational Algebra 
Relational Model 
Lecture 5 
Lectures 3 &4 
admission.edhole.com
Review: Where have we been? 
Where are we going next? 
Theory Practice 
Query Optimization 
and Execution 
Relational Operators 
Files and Access Methods 
Buffer Management 
Disk Space Management 
DB 
Relational Calculus Today 
Lecture 2 
Relational Algebra 
Relational Model 
Lecture 5 
Lectures 3 &4 
admission.edhole.com
Where are we going next? 
Practice 
Query Optimization 
and Execution 
Relational Operators 
Files and Access Methods 
Buffer Management 
Disk Space Management 
DB 
SQL 
On Deck: 
Practical 
ways of 
evaluating 
SQL 
admission.edhole.com
Review – Why do we need Query 
Languages anyway? 
• Two key advantages 
– Less work for user asking query 
– More opportunities for optimization 
• Relational Algebra 
– Theoretical foundation for SQL 
– Higher level than programming language 
• but still must specify steps to get desired result 
• Relational Calculus 
– Formal foundation for Query-by-Example 
– A first-order logic description of desired result 
– Only specify desired result, not how to get it 
admission.edhole.com
Relational Algebra Review 
Reserves Sailors Boats 
Additional operations: 
•Intersection (Ç) 
•Join ( ) 
•Division ( / ) 
sid sname rating age 
22 dustin 7 45.0 
31 lubber 8 55.5 
58 rusty 10 35.0 
bid bname color 
101 Interlake Blue 
102 Interlake Red 
103 Clipper Green 
104 Marine Red 
sid bid day 
22 101 10/10/96 
58 103 11/12/96 
Basic operations: 
•Selection ( σ ) 
•Projection ( π ) 
•Cross-product ( ´ ) 
•Set-difference ( — ) 
•Union ( È ) 
: gives a subset of rows. 
: deletes unwanted columns. 
: combine two relations. 
: tuples in relation 1, but not 2 
: tuples in relation 1 and 2. 
Query Optimization 
and Execution 
Relational Operators 
Files and Access Methods 
Buffer Management 
Disk Space Management 
:tuples in both relations. 
:like ´ but only keep tuples where common fields are equal. 
:tuples from relation 1 with matches in relation 2 
DB 
Prediction: These 
relational operators 
are going to look 
hauntingly familiar 
when we get to 
them…! 
admission.edhole.com
Relational Algebra Review 
Reserves Sailors Boats 
Additional operations: 
•Intersection (Ç) 
•Join ( ) 
•Division ( / ) 
sid sname rating age 
22 dustin 7 45.0 
31 lubber 8 55.5 
58 rusty 10 35.0 
bid bname color 
101 Interlake Blue 
102 Interlake Red 
103 Clipper Green 
104 Marine Red 
sid bid day 
22 101 10/10/96 
58 103 11/12/96 
Basic operations: 
•Selection ( σ ) 
•Projection ( π ) 
•Cross-product ( ´ ) 
•Set-difference ( — ) 
•Union ( È ) 
Find names of sailors who’ve reserved a green boat 
π( s n a (m( e (σ c o l o r = ‘ G r e e n ’ B o a t s ) R e s e r v e s ) S a i)lors) 
admission.edhole.com
Relational Algebra Review 
Reserves Sailors Boats 
sid sname rating age 
22 dustin 7 45.0 
31 lubber 8 55.5 
58 rusty 10 35.0 
bid bname color 
101 Interlake Blue 
102 Interlake Red 
103 Clipper Green 
104 Marine Red 
sid bid day 
22 101 10/10/96 
58 103 11/12/96 
Or better yet: 
Find names of sailors who’ve reserved a green boat 
(σ color=‘Green’Boats) 
( Reserves) π( bid ) 
π( sid ) 
( Sailors) 
π ( sname ) 
 Given the previous algebra, a query optimizer would replace it with this! 
admission.edhole.com
Intermission 
• Some algebra exercises for you to practice with are out 
on the class web site 
• Algebra and calculus exercises make for good exam 
questions! 
admission.edhole.com
Today: Relational Calculus 
• High-level, first-order logic description 
– A formal definition of what you want from the database 
• e.g. English: 
“Find all sailors with a rating above 7” 
In Calculus: 
{S |S Î Sailors Ù S.rating  7} 
“From all that is, find me the set of things that are tuples in the Sailors 
relation and whose rating field is greater than 7.” 
• Two flavors: 
– Tuple relational calculus (TRC) (Like SQL) 
– Domain relational calculus (DRC) (Like QBE) 
admission.edhole.com
Relational Calculus Building Blocks 
• Variables 
TRC: Variables are bound to tuples. 
DRC: Variables are bound to domain elements (= column values) 
• Constants 
7, “Foo”, 3.14159, etc. 
• Comparison operators 
=, , , , etc. 
• Logical connectives 
Ø - not 
Ù – and 
Ú - or 
Þ- implies 
Î - is a member of 
• Quantifiers 
X(p(X)): For every X, p(X) must be true 
$X(p(X)): There exists at least one X such admission.edhole.com that p(X) is true
Relational Calculus 
sid sname rating age 
28 yuppy 9 35.0 
31 lubber 8 55.5 
44 guppy 5 35.0 
58 rusty 10 35.0 
• English example: Find all sailors with a rating above 7 
– Tuple R.C.: 
{S |S ÎSailors Ù S.rating  7} 
“From all that is, find me the set of things that are tuples in the Sailors 
relation and whose rating field is greater than 7.” 
– Domain R.C.: 
{S,N,R,A| S,N,R,A ÎSailors Ù R  7} 
“From all that is, find me column values S, N, R, and A, where S is an 
integer, N is a string, R is an integer, A is a floating point number, 
such that S, N, R, A is a tuple in the Sailors relation and R is 
greater than 7.” 
admission.edhole.com
Tuple Relational Calculus 
• Query form: {T | p(T)} 
– T is a tuple and p(T) denotes a formula in which tuple 
variable T appears. 
• Answer: 
– set of all tuples T for which the formula p(T) evaluates to 
true. 
• Formula is recursively defined: 
– Atomic formulas get tuples from relations or compare 
values 
– Formulas built from other formulas using logical operators. 
admission.edhole.com
TRC Formulas 
• An atomic formula is one of the following: 
R Î Rel 
R.a op S.b 
R.a op constant, where 
op is one of 
,,=,£,³,¹ 
• A formula can be: 
– an atomic formula 
– where p and q are formulas 
– where variable R is a tuple variable 
– where variable R is a tuple variable 
Øp, pÙq, pÚq 
$R(p(R)) 
R(p(R)) 
admission.edhole.com
Free and Bound Variables 
• The use of quantifiers X and $X in a formula is said to 
bind X in the formula. 
– A variable that is not bound is free. 
• Important restriction 
{T | p(T)} 
– The variable T that appears to the left of `|’ must be the 
only free variable in the formula p(T). 
– In other words, all other tuple variables must be bound 
using a quantifier. 
admission.edhole.com
Use of  (For every) 
 x (P(x)): 
only true if P(x) is true for every x in the universe: 
e.g. x ((x.color = “Red”) 
means everything that exists is red 
• Usually we are less grandiose in our assertions: 
x ( (x Î Boats) Þ (x.color = “Red”) 
 Þ is a logical implication 
a Þ b means that if a is true, b must be true 
a Þ b is the same as Øa Ú b 
admission.edhole.com
a Þ b is the same as Øa Ú b 
• If a is true, b must be 
true! 
– If a is true and b is 
false, the expression 
evaluates to false. 
• If a is not true, we don’t 
care about b 
– The expression is 
always true. 
a 
T 
F 
b 
T F 
F 
T 
T T 
admission.edhole.com
Quantifier Shortcuts 
 x ((x Î Boats) Þ (x.color = “Red”)) 
“For every x in the Boats relation, the color must be Red.” 
Can also be written as: 
x Î Boats(x.color = “Red”) 
 $x ( (x Î Boats) Ù (x.color = “Red”)) 
“There exists a tuple x in the Boats relation whose 
color is Red.” 
Can also be written as: 
$x Î Boats (x.color = “Red”) 
admission.edhole.com
Selection and Projection 
• Selection 
Find all sailors with rating above 8 
{S |S ÎSailors Ù S.rating  8} 
S1 
S1 
S1 
S1 
• Projection 
Find names and ages of sailors with rating above 8. 
{S | $S1 ÎSailors(S1.rating  8 
sid sname rating age 
28 yuppy 9 35.0 
31 lubber 8 55.5 
44 guppy 5 35.0 
58 rusty 10 35.0 
Ù S.sname = S1.sname 
Ù S.age = S1.age)} 
sname age 
S 
yuppy 35.0 
S rusty 35.0 
S is a tuple variable of 2 fields (i.e. {S} is a projection of Sailors) 
admission.edhole.com
Joins 
Find sailors rated  7 who’ve reserved 
boat #103 
{S | SÎSailors Ù S.rating  7 Ù 
$R(RÎReserves Ù R.sid = S.sid 
Ù R.bid = 103)} 
sid sname rating age 
22 dustin 7 45.0 
31 lubber 8 55.5 
58 rusty 10 35.0 
sid bid day 
22 101 10/10/96 
58 103 11/12/96 
S 
S 
S 
R 
R 
Note the use of $ to find a tuple in Reserves that `joins with’ 
the Sailors tuple under consideration. 
What if there was another tuple {58, 103, 12/13/96} in the 
admRiessseirovnes. eredlahtioonle?. c om
Joins (continued) 
What does this expression compute? 
Find sailors rated  7 who’ve reserved a red boat 
{S | SÎSailors Ù S.rating  7 Ù 
$R(RÎReserves Ù R.sid = S.sid 
Ù $B(BÎBoats Ù B.bid = R.bid 
Ù B.color = ‘red’))} 
Notice how the parentheses control the scope of each quantifier’s binding. 
admission.edhole.com
Division 
•Recall the algebra expression A/B… 
A value x in A is disqualified if by attaching a y value from B, we obtain an xy 
tuple that is not in A. (e.g: only give me A tuples that have a match in B. 
In calculus, use the  operator: 
e.g. Find sailors who’ve reserved all boats: 
{S | SÎSailors Ù 
BÎBoats ($RÎReserves 
Find all sailors S such that… 
(S.sid = R.sid 
Ù B.bid = R.bid))} 
For all tuples B in Boats… 
There is at least one tuple in Reserves… 
showing that sailor S has reserved B. 
admission.edhole.com
More Calculus exercises on the web site… 
admission.edhole.com
Unsafe Queries, Expressive Power 
• $ syntactically correct calculus queries that have an 
infinite number of answers! These are unsafe queries. 
– e.g., 
S|ØSÎSailors æ  
ç  
ç  
è  
ü  
ý  
ö  
ï  
ïþ   
÷  
÷  
ø  
ì  
í  
ï  
îï   
– Solution???? Don’t do that! 
   
• Expressive Power (Theorem due to Codd): 
– Every query that can be expressed in relational algebra 
can be expressed as a safe query in DRC / TRC; the 
converse is also true. 
• Relational Completeness : Query languages (e.g., 
SQL) can express every query that is expressible in 
relational algebra/calculus. (actually, SQL is more 
powerful, as we will see…) 
admission.edhole.com
Relational Completeness means… 
Theory Practice 
Query Optimization 
and Execution 
Relational Operators 
Files and Access Methods 
Buffer Management 
Disk Space Management 
DB 
Relational Calculus 
Relational Algebra 
Relational Model 
admission.edhole.com
Now we can study SQL! 
Practice 
Query Optimization 
and Execution 
Relational Operators 
Files and Access Methods 
Buffer Management 
Disk Space Management 
DB 
SQL 
admission.edhole.com
Summary 
• The relational model has rigorously defined query languages 
that are simple and powerful. 
– Algebra and safe calculus have same expressive power 
• Relational algebra is more operational 
– useful as internal representation for query evaluation plans. 
… they’ll be baa-aack…. 
• Relational calculus is more declarative 
– users define queries in terms of what they want, not in 
terms of how to compute it. 
• Almost every query can be expressed several ways 
– and that’s what makes query optimization fun! 
admission.edhole.com

More Related Content

Similar to Admission in india 2015

lecture9Calc.ppt
lecture9Calc.pptlecture9Calc.ppt
lecture9Calc.pptrituah
 
Relational calculas
Relational calculasRelational calculas
Relational calculasanuj24
 
lefg sdfg ssdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg d...
lefg sdfg ssdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg d...lefg sdfg ssdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg d...
lefg sdfg ssdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg d...RajuNestham1
 
Relational Algebra
Relational AlgebraRelational Algebra
Relational AlgebraAmin Omi
 
Chapter-7 Relational Calculus
Chapter-7 Relational CalculusChapter-7 Relational Calculus
Chapter-7 Relational CalculusKunal Anand
 
Relational Algebra and Calculus.ppt
Relational Algebra and Calculus.pptRelational Algebra and Calculus.ppt
Relational Algebra and Calculus.pptAnkush138
 
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 PATELShashi Patel
 
leanCoR: lean Connection-based DL Reasoner
leanCoR: lean Connection-based DL ReasonerleanCoR: lean Connection-based DL Reasoner
leanCoR: lean Connection-based DL ReasonerAdriano Melo
 
Intro to relational model
Intro to relational modelIntro to relational model
Intro to relational modelATS SBGI MIRAJ
 
Database managment System Relational Algebra
Database managment System  Relational AlgebraDatabase managment System  Relational Algebra
Database managment System Relational AlgebraUttara University
 
6 - Relational Calculus.pdf
6 - Relational Calculus.pdf6 - Relational Calculus.pdf
6 - Relational Calculus.pdfgaurav70287
 

Similar to Admission in india 2015 (20)

lecture9Calc.ppt
lecture9Calc.pptlecture9Calc.ppt
lecture9Calc.ppt
 
Relational calculas
Relational calculasRelational calculas
Relational calculas
 
Relational Calculus
Relational CalculusRelational Calculus
Relational Calculus
 
lecture8Alg.ppt
lecture8Alg.pptlecture8Alg.ppt
lecture8Alg.ppt
 
lefg sdfg ssdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg d...
lefg sdfg ssdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg d...lefg sdfg ssdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg d...
lefg sdfg ssdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg sdfg d...
 
Relational Algebra
Relational AlgebraRelational Algebra
Relational Algebra
 
Chapter-7 Relational Calculus
Chapter-7 Relational CalculusChapter-7 Relational Calculus
Chapter-7 Relational Calculus
 
Relational Algebra and Calculus.ppt
Relational Algebra and Calculus.pptRelational Algebra and Calculus.ppt
Relational Algebra and Calculus.ppt
 
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
 
leanCoR: lean Connection-based DL Reasoner
leanCoR: lean Connection-based DL ReasonerleanCoR: lean Connection-based DL Reasoner
leanCoR: lean Connection-based DL Reasoner
 
Intro to relational model
Intro to relational modelIntro to relational model
Intro to relational model
 
Database managment System Relational Algebra
Database managment System  Relational AlgebraDatabase managment System  Relational Algebra
Database managment System Relational Algebra
 
DBMS CS3
DBMS CS3DBMS CS3
DBMS CS3
 
Algebra
AlgebraAlgebra
Algebra
 
lecture05-14f.ppt
lecture05-14f.pptlecture05-14f.ppt
lecture05-14f.ppt
 
Sql server select queries ppt 18
Sql server select queries ppt 18Sql server select queries ppt 18
Sql server select queries ppt 18
 
Relational Algebra
Relational AlgebraRelational Algebra
Relational Algebra
 
asal12 sqliii
asal12 sqliiiasal12 sqliii
asal12 sqliii
 
Compilation
CompilationCompilation
Compilation
 
6 - Relational Calculus.pdf
6 - Relational Calculus.pdf6 - Relational Calculus.pdf
6 - Relational Calculus.pdf
 

More from Edhole.com

Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarkaEdhole.com
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarkaEdhole.com
 
Website development company surat
Website development company suratWebsite development company surat
Website development company suratEdhole.com
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in suratEdhole.com
 
Website dsigning company in india
Website dsigning company in indiaWebsite dsigning company in india
Website dsigning company in indiaEdhole.com
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhiEdhole.com
 
Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarkaEdhole.com
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarkaEdhole.com
 
Website development company surat
Website development company suratWebsite development company surat
Website development company suratEdhole.com
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in suratEdhole.com
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in indiaEdhole.com
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhiEdhole.com
 
Website designing company in mumbai
Website designing company in mumbaiWebsite designing company in mumbai
Website designing company in mumbaiEdhole.com
 
Website development company surat
Website development company suratWebsite development company surat
Website development company suratEdhole.com
 
Website desinging company in surat
Website desinging company in suratWebsite desinging company in surat
Website desinging company in suratEdhole.com
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in indiaEdhole.com
 

More from Edhole.com (20)

Ca in patna
Ca in patnaCa in patna
Ca in patna
 
Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarka
 
Ca in dwarka
Ca in dwarkaCa in dwarka
Ca in dwarka
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarka
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in surat
 
Website dsigning company in india
Website dsigning company in indiaWebsite dsigning company in india
Website dsigning company in india
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhi
 
Ca in patna
Ca in patnaCa in patna
Ca in patna
 
Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarka
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarka
 
Ca in dwarka
Ca in dwarkaCa in dwarka
Ca in dwarka
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in surat
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in india
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhi
 
Website designing company in mumbai
Website designing company in mumbaiWebsite designing company in mumbai
Website designing company in mumbai
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
 
Website desinging company in surat
Website desinging company in suratWebsite desinging company in surat
Website desinging company in surat
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in india
 

Recently uploaded

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 

Recently uploaded (20)

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
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🔝
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 

Admission in india 2015

  • 1. Admission in India 2015 By: admission.edhole.com
  • 2. Relational Calculus CS 186, Spring 2007, Lecture 6 R&G, Chapter 4 $ Mary Roth " We will occasionally use this arrow notation unless there is danger of no confusion. Ronald Graham Elements of Ramsey Theory admission.edhole.com
  • 3. Administrivia • Homework 1 due in 1 week – Thursday, Feb 8 10 p.m. • New syllabus on web site • Questions? admission.edhole.com
  • 4. Review • Database Systems have both theory and practice • It’s a systems course, so we are heavy on the practice • But our practice has to have theory to back it up 8-) • …so we will be looking at both of them in parallel admission.edhole.com
  • 5. Review: Where have we been? Theory Practice Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management DB Lecture 2 Relational Algebra Relational Model Lecture 5 Lectures 3 &4 admission.edhole.com
  • 6. Review: Where have we been? Where are we going next? Theory Practice Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management DB Relational Calculus Today Lecture 2 Relational Algebra Relational Model Lecture 5 Lectures 3 &4 admission.edhole.com
  • 7. Where are we going next? Practice Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management DB SQL On Deck: Practical ways of evaluating SQL admission.edhole.com
  • 8. Review – Why do we need Query Languages anyway? • Two key advantages – Less work for user asking query – More opportunities for optimization • Relational Algebra – Theoretical foundation for SQL – Higher level than programming language • but still must specify steps to get desired result • Relational Calculus – Formal foundation for Query-by-Example – A first-order logic description of desired result – Only specify desired result, not how to get it admission.edhole.com
  • 9. Relational Algebra Review Reserves Sailors Boats Additional operations: •Intersection (Ç) •Join ( ) •Division ( / ) sid sname rating age 22 dustin 7 45.0 31 lubber 8 55.5 58 rusty 10 35.0 bid bname color 101 Interlake Blue 102 Interlake Red 103 Clipper Green 104 Marine Red sid bid day 22 101 10/10/96 58 103 11/12/96 Basic operations: •Selection ( σ ) •Projection ( π ) •Cross-product ( ´ ) •Set-difference ( — ) •Union ( È ) : gives a subset of rows. : deletes unwanted columns. : combine two relations. : tuples in relation 1, but not 2 : tuples in relation 1 and 2. Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management :tuples in both relations. :like ´ but only keep tuples where common fields are equal. :tuples from relation 1 with matches in relation 2 DB Prediction: These relational operators are going to look hauntingly familiar when we get to them…! admission.edhole.com
  • 10. Relational Algebra Review Reserves Sailors Boats Additional operations: •Intersection (Ç) •Join ( ) •Division ( / ) sid sname rating age 22 dustin 7 45.0 31 lubber 8 55.5 58 rusty 10 35.0 bid bname color 101 Interlake Blue 102 Interlake Red 103 Clipper Green 104 Marine Red sid bid day 22 101 10/10/96 58 103 11/12/96 Basic operations: •Selection ( σ ) •Projection ( π ) •Cross-product ( ´ ) •Set-difference ( — ) •Union ( È ) Find names of sailors who’ve reserved a green boat π( s n a (m( e (σ c o l o r = ‘ G r e e n ’ B o a t s ) R e s e r v e s ) S a i)lors) admission.edhole.com
  • 11. Relational Algebra Review Reserves Sailors Boats sid sname rating age 22 dustin 7 45.0 31 lubber 8 55.5 58 rusty 10 35.0 bid bname color 101 Interlake Blue 102 Interlake Red 103 Clipper Green 104 Marine Red sid bid day 22 101 10/10/96 58 103 11/12/96 Or better yet: Find names of sailors who’ve reserved a green boat (σ color=‘Green’Boats) ( Reserves) π( bid ) π( sid ) ( Sailors) π ( sname ) Given the previous algebra, a query optimizer would replace it with this! admission.edhole.com
  • 12. Intermission • Some algebra exercises for you to practice with are out on the class web site • Algebra and calculus exercises make for good exam questions! admission.edhole.com
  • 13. Today: Relational Calculus • High-level, first-order logic description – A formal definition of what you want from the database • e.g. English: “Find all sailors with a rating above 7” In Calculus: {S |S Î Sailors Ù S.rating 7} “From all that is, find me the set of things that are tuples in the Sailors relation and whose rating field is greater than 7.” • Two flavors: – Tuple relational calculus (TRC) (Like SQL) – Domain relational calculus (DRC) (Like QBE) admission.edhole.com
  • 14. Relational Calculus Building Blocks • Variables TRC: Variables are bound to tuples. DRC: Variables are bound to domain elements (= column values) • Constants 7, “Foo”, 3.14159, etc. • Comparison operators =, , , , etc. • Logical connectives Ø - not Ù – and Ú - or Þ- implies Î - is a member of • Quantifiers X(p(X)): For every X, p(X) must be true $X(p(X)): There exists at least one X such admission.edhole.com that p(X) is true
  • 15. Relational Calculus sid sname rating age 28 yuppy 9 35.0 31 lubber 8 55.5 44 guppy 5 35.0 58 rusty 10 35.0 • English example: Find all sailors with a rating above 7 – Tuple R.C.: {S |S ÎSailors Ù S.rating 7} “From all that is, find me the set of things that are tuples in the Sailors relation and whose rating field is greater than 7.” – Domain R.C.: {S,N,R,A| S,N,R,A ÎSailors Ù R 7} “From all that is, find me column values S, N, R, and A, where S is an integer, N is a string, R is an integer, A is a floating point number, such that S, N, R, A is a tuple in the Sailors relation and R is greater than 7.” admission.edhole.com
  • 16. Tuple Relational Calculus • Query form: {T | p(T)} – T is a tuple and p(T) denotes a formula in which tuple variable T appears. • Answer: – set of all tuples T for which the formula p(T) evaluates to true. • Formula is recursively defined: – Atomic formulas get tuples from relations or compare values – Formulas built from other formulas using logical operators. admission.edhole.com
  • 17. TRC Formulas • An atomic formula is one of the following: R Î Rel R.a op S.b R.a op constant, where op is one of ,,=,£,³,¹ • A formula can be: – an atomic formula – where p and q are formulas – where variable R is a tuple variable – where variable R is a tuple variable Øp, pÙq, pÚq $R(p(R)) R(p(R)) admission.edhole.com
  • 18. Free and Bound Variables • The use of quantifiers X and $X in a formula is said to bind X in the formula. – A variable that is not bound is free. • Important restriction {T | p(T)} – The variable T that appears to the left of `|’ must be the only free variable in the formula p(T). – In other words, all other tuple variables must be bound using a quantifier. admission.edhole.com
  • 19. Use of (For every) x (P(x)): only true if P(x) is true for every x in the universe: e.g. x ((x.color = “Red”) means everything that exists is red • Usually we are less grandiose in our assertions: x ( (x Î Boats) Þ (x.color = “Red”) Þ is a logical implication a Þ b means that if a is true, b must be true a Þ b is the same as Øa Ú b admission.edhole.com
  • 20. a Þ b is the same as Øa Ú b • If a is true, b must be true! – If a is true and b is false, the expression evaluates to false. • If a is not true, we don’t care about b – The expression is always true. a T F b T F F T T T admission.edhole.com
  • 21. Quantifier Shortcuts x ((x Î Boats) Þ (x.color = “Red”)) “For every x in the Boats relation, the color must be Red.” Can also be written as: x Î Boats(x.color = “Red”) $x ( (x Î Boats) Ù (x.color = “Red”)) “There exists a tuple x in the Boats relation whose color is Red.” Can also be written as: $x Î Boats (x.color = “Red”) admission.edhole.com
  • 22. Selection and Projection • Selection Find all sailors with rating above 8 {S |S ÎSailors Ù S.rating 8} S1 S1 S1 S1 • Projection Find names and ages of sailors with rating above 8. {S | $S1 ÎSailors(S1.rating 8 sid sname rating age 28 yuppy 9 35.0 31 lubber 8 55.5 44 guppy 5 35.0 58 rusty 10 35.0 Ù S.sname = S1.sname Ù S.age = S1.age)} sname age S yuppy 35.0 S rusty 35.0 S is a tuple variable of 2 fields (i.e. {S} is a projection of Sailors) admission.edhole.com
  • 23. Joins Find sailors rated 7 who’ve reserved boat #103 {S | SÎSailors Ù S.rating 7 Ù $R(RÎReserves Ù R.sid = S.sid Ù R.bid = 103)} sid sname rating age 22 dustin 7 45.0 31 lubber 8 55.5 58 rusty 10 35.0 sid bid day 22 101 10/10/96 58 103 11/12/96 S S S R R Note the use of $ to find a tuple in Reserves that `joins with’ the Sailors tuple under consideration. What if there was another tuple {58, 103, 12/13/96} in the admRiessseirovnes. eredlahtioonle?. c om
  • 24. Joins (continued) What does this expression compute? Find sailors rated 7 who’ve reserved a red boat {S | SÎSailors Ù S.rating 7 Ù $R(RÎReserves Ù R.sid = S.sid Ù $B(BÎBoats Ù B.bid = R.bid Ù B.color = ‘red’))} Notice how the parentheses control the scope of each quantifier’s binding. admission.edhole.com
  • 25. Division •Recall the algebra expression A/B… A value x in A is disqualified if by attaching a y value from B, we obtain an xy tuple that is not in A. (e.g: only give me A tuples that have a match in B. In calculus, use the operator: e.g. Find sailors who’ve reserved all boats: {S | SÎSailors Ù BÎBoats ($RÎReserves Find all sailors S such that… (S.sid = R.sid Ù B.bid = R.bid))} For all tuples B in Boats… There is at least one tuple in Reserves… showing that sailor S has reserved B. admission.edhole.com
  • 26. More Calculus exercises on the web site… admission.edhole.com
  • 27. Unsafe Queries, Expressive Power • $ syntactically correct calculus queries that have an infinite number of answers! These are unsafe queries. – e.g., S|ØSÎSailors æ ç ç è ü ý ö ï ïþ ÷ ÷ ø ì í ï îï – Solution???? Don’t do that!   • Expressive Power (Theorem due to Codd): – Every query that can be expressed in relational algebra can be expressed as a safe query in DRC / TRC; the converse is also true. • Relational Completeness : Query languages (e.g., SQL) can express every query that is expressible in relational algebra/calculus. (actually, SQL is more powerful, as we will see…) admission.edhole.com
  • 28. Relational Completeness means… Theory Practice Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management DB Relational Calculus Relational Algebra Relational Model admission.edhole.com
  • 29. Now we can study SQL! Practice Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management DB SQL admission.edhole.com
  • 30. Summary • The relational model has rigorously defined query languages that are simple and powerful. – Algebra and safe calculus have same expressive power • Relational algebra is more operational – useful as internal representation for query evaluation plans. … they’ll be baa-aack…. • Relational calculus is more declarative – users define queries in terms of what they want, not in terms of how to compute it. • Almost every query can be expressed several ways – and that’s what makes query optimization fun! admission.edhole.com