Selection and projection

The vocabulary of relational algebra (relation, tuple, degree, cardinality) and the two operators that filter a relation: selection σ keeps rows, projection π keeps columns and removes duplicates.

  • 29 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

  • Relation: what is it?

    Show the answer

    A set of tuples with the same schema, drawn as a table with no duplicate row and no order among the rows.

    Since it is a set, two identical tuples cannot coexist in it: that is why projection can reduce the number of rows.

  • On this relation, what does π nom(σ ville = 'Paris'(CLIENT)) return?

    ```text
    CLIENT(id, nom, ville, age)
    1 Durand Lyon 34
    2 Morel Paris 28
    3 Petit Lyon 45
    4 Bernard Lille 28
    5 Roux Paris 51
    6 Faure Lyon 28
    7 Lopez Nantes 39
    8 Girard Paris 22
    `

    • Morel, Roux and Girard
    • Paris, Paris and Paris
    • Durand, Petit and Faure
    • Morel and Roux only
    Show the answer

    Morel, Roux and Girard

    σ first keeps the three tuples whose city is Paris, then π keeps only the nom column. Read from the inside out.

  • A relation is a … of tuples: it therefore never contains two … tuples.

    Show the answer

    A relation is a set of tuples: it therefore never contains two identical tuples.

    SQL, for its part, accepts duplicates in its results; it is DISTINCT that restores the behaviour of projection.

  • Tuple: what is it?

    Show the answer

    One row of a relation: one value for each of the schema's attributes.

    (1, Durand, Lyon, 34) is a tuple of CLIENT; it carries as many values as the schema has attributes.