Relational algebra - Theoretical Flashcards
Learn the five fundamental database operations and how they work
What is relational algebra?
It is a formal language that created to formally describe relational databases
What is a relation?
A table
What is a closure in relational algebra?
It is a nested query (subquery) which output is used in the outer query.
e.g: SELECT * FROM Employees WHERE DName = (SELECT Dname From Departments WHERE Dname = "Research")
How many operations are there in relational algebra?
Originally it included 8 but more have been added since..
What is a unary operation?
An operation that only involves one single relation (1 table)
How many fundamental operations are there in relational algebra?
Five;
- selection
- projection
- Cartesian product
- union
- minus.
What are the additional operations besides the fundamental ones in relational algebra??
Join
intersection
Division operations
What is a binary operation?
an operation that do work on two relations (2 tables) and results in a single table (it shows the result in a new table).
What is the selection operation?
Unary operation (works on a single table), it defines a new relation (table) with all the tuples (rows) that is selected (satisfy condition)
What is the projection operation?
Unary operation that outputs a new relation that contains all the columns of given attributes.
e.g. all names that exist in the table, by selecting all names and phonenumbers.
What is the union operation?
Binary operation(two relations) Outputs one relation that contains all the tuples of the two relations without duplications
What are the requirements of the union operation?
The schemas must match; same number of attributes and the corresponding attributes has the same domain (but naming is irrelevant)
What is the minus operation?
Binary operation that defines a relation consisting of tuples that are in one but not the other.. So rows that only exist in one of the tables
opposite of intersection
What is the intersection operation?
binary operation that results in a relation that consist of only the tuples that exist in both realtions.
Rename operation
unary operation that gives new names to a relation or attributes.