Download presentation
Presentation is loading. Please wait.
Published byBuck Stevenson 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
4
16.3. SQL/RAE of Figure 16.19 select distinct movietitle from starsIn a, (select name from moviestar where birthdate like '%1974%') temp where a.starname = temp.name; RAE=Relational Algebra Expressible SQL
6
16.3Example16.19 Figure 16.24 π movie title σ movieYear lile ‘%1974’ StarsIn This is the RAE SQL π name MovieStar starname=name
7
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;
9
16.3Example16.19 Figure 16.24 π movie title σ movieYear lile ‘%1974%’ StarsIn This is the RAE SQL π name MovieStar starname=name starame, movie title
10
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 );
12
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;
14
γ 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
15
γ 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
16
γ m2.movieTitle, m2.movieyear,AVG(birthDate) ave m1.movieYear -40 abd π m1.movieYear m1.movieYear m2,starname=s.name StaesIn MovieStar
17
γ 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
18
Lecture on Whiteboard Select P.PNAME, Sum (S.QTY) From Parts P, Shipments S Where P.PNUM = S.SNUM Group by PNAME;
19
Lecture on Whiteboard pname,SUM(qty) -->sum (Natural Join) Shipments Parts pname,SUM(qty) -->sum (Shipment Parts)
20
Lecture on Whiteboard Select F.PNAME, Sum (F.QTY) as sum From ( Select PNAME, QTY FROM ( SELECT PNUM,PNAME From Parts) P, ( Select PNUM, QTY From Shipments) S where P.PNUM=S.PNUM )F Group by F.pname;
21
pname,SUM(qty) -->sum pname. qty (Natural join) π pnum,qty π pnum, pname Shipments Parts
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.