Search code examples
sqlrelational-algebra

Select * in Relational Algebra


Please explain how to express this SQL statement in relational algebra

select * from Books

When I search I could find a lot of examples with where clause, I just need to verify that it is σ Books or the answer is something else.


Solution

  • It's

    Books
    

    Relational algebra operators take relation values (among other values) as input and return them as output. Typically a relational algebra query language is or includes expressions that are nested calls to operators. (Don't confuse values & operators with expressions that denote values, via the names of operators & values.) The nesting has to end at leaf expressions denoting relation values. They can be literals describing relations in terms of their parts. Or they can be names of given relation constants or variables. Books is such a name. So a query expression returning its value is the expression Books. If that wasn't a valid expression for a relation value then you couldn't use it as an argument in a call to an operator in a query expression.