5) Relational Algebra Flashcards
(47 cards)
What is the union operation in set operations?
Combine two sets by including all elements from both sets, with no duplicates.
For example, R1 ∪ R2 includes all unique elements from both R1 and R2.
What does the intersection operation do?
Find common elements between two sets.
Intersection is represented by the symbol ∩.
What is the difference operation in set operations?
Find elements that are in one set but not in the other.
The difference operation is denoted by the symbol .
What does the Cartesian product operation do?
Combine two sets in every possible way by pairing each element from the first set with each element from the second set.
It is represented by the symbol ×.
Define projection in relational databases.
Select specific columns from a table to display, creating new rows with only the selected columns.
Notation: πx(r) = {t[X] | t ∈ r}, where X is a subset of attributes.
What is the purpose of selection in relational databases?
Filter rows from a table based on a condition.
Notation: σC(R) selects rows from relation R that satisfy condition C.
What does a join operation do in relational databases?
Combine two tables based on a common column to create a new table.
In a join, a row from R1 can match with more than one row in R2.
What is a unary operation in relational algebra?
An operation that works on one table.
Examples include selection and projection.
What is the result of a Cartesian product R x S if R has 2 rows and S has 3?
R x S will have 6 rows.
The new table T will contain all columns from both R and S.
What does it mean for R and S to have the same arity?
They have the same number of columns.
This is required for union, difference, and intersection operations.
What is an equijoin?
A type of join that uses a filter between columns to determine which rows to join.
Example: R(B) < S(D) joins rows where R(B) is less than S(D).
True or False: Joins are the most expensive operation of relational algebra.
True.
Comparing all pairs of tuples takes O(n^2) time.
What is the time complexity for a better way to do a natural join or equijoin?
O(m + 2n log n).
This method involves sorting both tables by the join attributes.
What is the purpose of division in relational algebra?
To find values related to all values in another set.
Example: R(A,B) = students and courses passed; S(B) = required courses.
What set of operations is considered complete in relational algebra?
{σ, π, ∪, −, ×}.
Any other operations can be expressed as sequences from this set.
What are aggregate functions in relational algebra?
Functions that go beyond basic operations, such as sum, average, maximum, minimum, and count.
Aggregate functions are used for summarizing data.
What is a limitation of relational algebra regarding recursive closure?
It does not inherently support hierarchical relationships.
Example: employees supervising each other in a circle.
What is the symbol for Union in set operations?
∪
What does the Union operation do?
Combine two sets by including all elements from both sets without duplicates.
What is the symbol for Intersection in set operations?
∩
What does the Intersection operation find?
Common elements between two sets.
What is the symbol for Difference in set operations?
\
What does the Difference operation identify?
Elements that are in one set but not in the other.
What is the symbol for Cartesian product in set operations?
×