Review 3:Bags Model SQL,the most important query language for relational databases is actually a bag language. SOL will eliminate duplicates,but usually only if you ask it to do so explicitly. Some operations,like projection, are much more efficient on bags than sets
Review 3: Bags Model SQL, the most important query language for relational databases is actually a bag language. SQL will eliminate duplicates, but usually only if you ask it to do so explicitly. Some operations, like projection, are much more efficient on bags than sets
Extended (Nonclassical") Relational Algebra Add features needed for SQL bags. 1.Duplicate-elimination operator 8 2. Extended projection. 3.Sorting operator t 4.Grouping-and-aggregation operator 5.Outerjoin operator o
Extended ( “Nonclassical ”) Relational Algebra Add features needed for SQL bags. 1. Duplicate-elimination operator δ 2. Extended projection. 3. Sorting operator τ 4. Grouping-and-aggregation operator γ 5. Outerjoin operator ∞°
Duplicate Elimination s(R)=relation with one copy of each tuple that appears one or more times in R. Example R A B 1 2 3 4 1 2 δ(R)= A B 1 2 3 4
Duplicate Elimination δ (R ) = relation with one copy of each tuple that appears one or more times in R. Example R = A B 1 2 3 4 1 2 δ (R ) = A B 1 2 3 4
Sorting (R)=list of tuples of R,ordered according to attributes on list L Note that result type is outside the normal types (set or bag)for relational algebra. Consequence,t cannot be followed by other relational operators. R= A B TB(R)=[(1,2),(5,2),(3,4)] 1 2 3 4 5 2
Sorting τL(R) = list of tuples of R, ordered according to attributes on list L Note that result type is outside the normal types (set or bag) for relational algebra. Consequence, τ cannot be followed by other relational operators. R = A B τ B(R ) = [(1,2), (5,2), (3,4)] 1 2 3 4 5 2
Extended Projection Allow the columns in the projection to be functions of one or more columns in the argument relation. Example: R-A B 元A+B,A,A(R)= :A+B A1 A2 1 2 3 1 1 3 4 7 3 3 .Arithmetic on attributes .Duplicate occurrences of the same attribute
Extended Projection Allow the columns in the projection to be functions of one or more columns in the argument relation. Example: R = A B π A+B,A,A (R)= A+B A1 A2 1 2 3 1 1 3 4 7 3 3 •Arithmetic on attributes •Duplicate occurrences of the same attribute