### Bags, sets and the δ and γ operators

• Bags and sets

• Bag and Set:

• Set = a collection of elements that do not contain duplicate elements

Example:

 ``` S = { 1, 2, 3 } ```

• Bag = a collection of elements that can contain duplicate elements

Example:

 ``` B = { 1, 2, 2, 3 } ```

• Relations in (1) Relational Algebra and in (2) a database system

• Recall: a relation per definition

 Relation in Relational Algebra (a mathematical language) is a set of tuples A set does not have duplicate values

• Database systems:

• All database systems implement a relation as a bag of tuples

Because:

 Detecting/Removing duplicate values requires extra overhead No extra work is performed to check/remove duplicate values by default Users can request the database system to remove duplicates using the "duplicate elimiation" operation

• The duplicate elimination operator δ

• δ: remove duplicates

• δ(B) = the set of tuples in (bag) B with duplicates removed

Example:

 δ({1, 2, 2, 3}) = {1, 2, 3}