Download presentation
Presentation is loading. Please wait.
Published byNia Wingett Modified over 9 years ago
1
16.3 Parser to Logical Query Plans
2
16.1. SQL(not RAE) Figure 16.2 select distinct movietitle from starsIn where starname in (select name from moviestar where birthdate like '%1974%'); NOTRAE=Relational Algebra NOT Expressible SQL
3
16.3. SQL/RAE of Figure 16.19 select distinct movietitle from starsIn a, (select name from moviestar where birthdate like '%1996%') temp where a.starname = temp.name; RAE=Relational Algebra Expressible SQL
4
16.3Example16.19 Figure 16.24 π movie title σ movieYear lile ‘%1996’ StarsIn This is the RAE SQL π name MovieStar starname=name
5
16.3. SQL/RAE of Figure 16.19 select movietitle from (select starname,movietitle From starsIn) a, (select name from moviestar where birthdate like '%1974%') b where a.starname = b.name;
6
16.3Example16.19 Figure 16.24 π movie title σ movieYear lile ‘%1974%’ StarsIn This is the RAE SQL π name MovieStar starname=name starame, movie title
7
SQL in Figure 16.20 Select distinct m1.movieTitle, m1.movieYear From StarsIn m1 Where m1.movieYear – 40 <= ( Select AVG(birthdate) From StarsIn m2, Moviestar s Where m2.starName=s.name AND m1.movieTitle = m2.movieTitle AND m1.movieyear = m2.movieyear );
8
SQL in Figure 16.22 Select distinct m.movieTitle, m.movieYear From StarsIn m1, ( Select m2.movieTitle, m2.movieyear, AVG(birthdate) as ave From StarsIn m2, Moviestar s Where m2.starName=s.name Group by m2.movieTitle, m2.movieyear ) m Where m1.movieTitle = m.movieTitle and m1.movieYear – 40 <=ave;
9
γ m2.movieTitle, m2.movieyear,AVG(birthDate) ave m2.movietitle=m1.movietitle and m2.movietitle=m1.movietitle m1.movieYear -40 abd π m1.movieYear m1.movieYear StarsIn m2,starname=s.name StaesIn MovieStar
10
γ m2.movieTitle, m2.movieyear,AVG(birthDate) ave m2.movietitle=m1.movietitle and m2.movietitle=m1.movietitle m1.movieYear -40 abd π m1.movieYear m1.movieYear StarsIn m2,starname=s.name StaesIn MovieStar π m1.movieYear,m1.movieYear
11
γ m2.movieTitle, m2.movieyear,AVG(birthDate) ave m1.movieYear -40 abd π m1.movieYear m1.movieYear m2,starname=s.name StaesIn MovieStar
12
γ m2.movieTitle, m2.movieyear,AVG(birthDate) ave m1.movieYear -40 abd π m1.movietitle m1.movieYear m2,starname=s.name StaesIn MovieStar m1.movietitle m1.movieYear
13
Lecture on Whiteboard Select PNAME, Sum (QTY) From Parts natural join Shipments Group by PNAME;
14
Lecture on Whiteboard pname,SUM(qty) -->sum (Natural Join) Shipments Parts pname,SUM(qty) -->sum (Shipment Parts)
15
Lecture on Whiteboard Select F.PNAME, Sum (F.QTY) as sum From ( Select PNAME, QTY FROM ( SELECT PNUM,PNAME From Parts) natural join ( Select PNUM, QTY From Shipments) )F Group by F.pname;
16
pname,MAX(qty) -->max pname. qty (Natural join) π pnum,qty π pnum, pname Shipments Parts
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.