07.03 cartesian product

bishalghimire 1,214 views 6 slides Jun 02, 2013
Slide 1
Slide 1 of 6
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6

About This Presentation

No description available for this slideshow.


Slide Content

DBMS Relational Algebra Cartesian Product Bishal Ghimire [email protected]

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.

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

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.

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

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 ) )