Union, intersection, difference

The three set operators of relational algebra: the schema compatibility condition, what each returns, the difference that is not commutative, and its use to express “those who have not”.

  • 23 cards
  • 4 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. The numbers

A few cards from the deck

  • Schema compatibility: what is it?

    Show the answer

    The condition for combining two relations with a set operator: the same number of attributes, with the same domains one by one.

    CLIENT(id, nom) and FOURNISSEUR(id, nom) are compatible; CLIENT(id, nom) and PRODUIT(ref, prix) are not, even with two columns, as the domains differ.

  • What does ABONNES_2023 − ABONNES_2024 return?

    ```text
    ABONNES_2023(id, nom) ABONNES_2024(id, nom)
    1 Durand 2 Morel
    2 Morel 4 Roux
    3 Petit 5 Faure
    4 Roux
    `

    • Durand and Petit
    • Faure
    • Morel and Roux
    • Durand, Petit and Faure
    Show the answer

    Durand and Petit

    You keep the 2023 tuples missing from 2024: Durand and Petit, who did not renew. Faure is a 2024 tuple, so not part of the difference in this direction.

  • Two relations are … for union when they have the same number of attributes, with the same domains one by one.

    Show the answer

    Two relations are compatible for union when they have the same number of attributes, with the same domains one by one.

    Otherwise tuples cannot be lined up column by column and the result would have no single schema.

  • Union (R ∪ S): what is it?

    Show the answer

    The relation made of every tuple present in either of the two relations, each written once.

    A tuple present in both R and S appears once, as a relation is a set: the cardinality is |R| + |S| − |R ∩ S|.