RA (Relational Algebra ) -- QL (Query Language). Reading: Chapter 2 Set of elements - set of relations Set of operations - RA operations Categories: 1. Set operations: union, difference, intersection 2. Remove parts : projection, selection 3. Combination : Cartesian product, joins 4. Renaming Union R1(S), R2(S), t R1 R2 Deposit_1 Min Weight Hard zircon 190 7.5 topaz 182 8 R = R1 R2 if t R1 t R2 Deposit_2 Min Weight Hard calcite 100 3 zircon 190 7.5 Deposit_1 Deposit_2 Min Weight Hard zircon 190 7.5 topaz 182 8 calcite 100 3 Difference R1(S), R2(S), R = R1 - R2 t R1 - R2 if t R1 t R2 Deposit_1 - Deposit_2 Min Weight Hard topaz 182 8 Deposit_2 - Deposit_1 Min Weight Hard calcite 100 3 Projection R(S), S' S, π S' R t' π S' R if Minerals Min Weight zircon 190 topaz 182 calcite 100 zircon 190 topaz 182 Hard 7.5 8 3 7.5 8 Streak white white white white white t' = restriction(t) S' , t R Color green blue white brown yellow π Min,Hard,Weight Minerals Min Hard Weight zircon 7.5 190 topaz 8 182 calcite 3 100 Selection R(S), σ C R C: attributes, const, comparisons, logical connectives t σ C R if t R, C(t) = true σ Weight>150 AND Hard<8 Minerals Min Weight Hard Streak Color zircon 190 7.5 white green zircon 190 7.5 white brown Cartesian product R1(S1), R2(S2), R(S), S = S1,S2, R = R1 R2 t R1 R2 if t = t1,t2, t1 R1, t2 R2 Branches Branch Address Br_1 Addr_1 Br_2 Addr_2 Br_3 Addr_3 Deposit_1 Branches Min Weight Hard zircon 190 7.5 zircon 190 7.5 zircon 190 7.5 topaz 182 8 topaz 182 8 topaz 182 8 Branch Br_1 Br_2 Br_3 Br_1 Br_2 Br_3 Address Addr_1 Addr_2 Addr_3 Addr_1 Addr_2 Addr_3 Basis: independent set of generators Intersection R1(S), R2(S), R = R1 R2 t R1 R2 if t R1 t R2 R = R1 - (R1 - R2) Deposit_1 Deposit_2 Min Weight Hard zircon 190 7.5 Joins: natural, theta, semi Natural join H_group Hard Group 3 soft 7 hard 8 hard Theta join R1(S1), R2(S2), R(S), S = S1 S2, A = S1 S2 R = π S (σ R1.A=R2.A (R1 R2)) Minerals | | H_group Min Weight Hard topaz 182 8 calcite 100 3 topaz 182 8 Streak white white white R1(S1), R2(S2), R(S), S = S1,S2, R = σ C (R1 R2) Minerals | | Color=white OR Color=blue H_group Min Weight Minerals.Hard Streak Color topaz 182 8 white blue topaz 182 8 white blue topaz 182 8 white blue calcite 100 3 white white calcite 100 3 white white calcite 100 3 white white Semi-join R1 | R2 = π S1 (R1 | | R2) R = R1 | | R2 Color blue white yellow Group hard soft hard R = R1 | | C R2 H_group.Hard 3 7 8 3 7 8 Group soft hard hard soft hard hard
© Copyright 2026 Paperzz