07.03 cartesian product
TRANSCRIPT
![Page 1: 07.03 cartesian product](https://reader038.vdocuments.pub/reader038/viewer/2022100604/559a6c921a28aba1028b464b/html5/thumbnails/1.jpg)
![Page 2: 07.03 cartesian product](https://reader038.vdocuments.pub/reader038/viewer/2022100604/559a6c921a28aba1028b464b/html5/thumbnails/2.jpg)
The rename operation
It is denoted as ρ
E : relational algebra expression
ρ x (E): returns the result of
expression E under the name x.
ρ x (A1, A2, A3… An) (E): returns the
result of expression E under the name
x with attributes renamed to A1, A2,
A3… An.
![Page 3: 07.03 cartesian product](https://reader038.vdocuments.pub/reader038/viewer/2022100604/559a6c921a28aba1028b464b/html5/thumbnails/3.jpg)
Rename Operator
The rename operator returns an existing relation
under a new name.
ρA(B) is the relation B with its name changed to A.
Name EmployeeId
Harry 3415
Sally 2241
EmployeeName EmployeeId
Harry 3415
Sally 2241
Employee
![Page 4: 07.03 cartesian product](https://reader038.vdocuments.pub/reader038/viewer/2022100604/559a6c921a28aba1028b464b/html5/thumbnails/4.jpg)
Cartesian Product
If R and S are two relations, R S is the set of all concatenated tuples <x,y>, where x is a tuple in R and y is a tuple in S
◦ R and S need not be union compatible.
◦ But R and S must have distinct attribute names.
Each row of R is paired with each row of S.
Result schema has one field per field of S
and R, with field names `inherited’ if
possible.
![Page 5: 07.03 cartesian product](https://reader038.vdocuments.pub/reader038/viewer/2022100604/559a6c921a28aba1028b464b/html5/thumbnails/5.jpg)
Cartesian Product
A B
a1 b1
a2 b2
C D
c1 d1
c2 d2
A B C D
a1 b1 c1 d1
a1 b1 c2 d2
a2 b2 c1 d1
a2 b2 c2 d2
R S
R x S
![Page 6: 07.03 cartesian product](https://reader038.vdocuments.pub/reader038/viewer/2022100604/559a6c921a28aba1028b464b/html5/thumbnails/6.jpg)
sID sName GPA HS sID sName major dec
Student Apply
Q : Names and GPAs of students with HS >1000 who
applied to CS and were rejected
π sName , GPA
( σ Student.sID = Apply.sID ^ HS > 1000 ^ Major =‘cs’ ^ dec = ‘R’
( Student x Apply ) )