5) Relational Algebra Flashcards

(47 cards)

1
Q

What is the union operation in set operations?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the intersection operation do?

A

Find common elements between two sets.

Intersection is represented by the symbol ∩.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference operation in set operations?

A

Find elements that are in one set but not in the other.

The difference operation is denoted by the symbol .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the Cartesian product operation do?

A

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 ×.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define projection in relational databases.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the purpose of selection in relational databases?

A

Filter rows from a table based on a condition.

Notation: σC(R) selects rows from relation R that satisfy condition C.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does a join operation do in relational databases?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a unary operation in relational algebra?

A

An operation that works on one table.

Examples include selection and projection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the result of a Cartesian product R x S if R has 2 rows and S has 3?

A

R x S will have 6 rows.

The new table T will contain all columns from both R and S.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does it mean for R and S to have the same arity?

A

They have the same number of columns.

This is required for union, difference, and intersection operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is an equijoin?

A

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).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

True or False: Joins are the most expensive operation of relational algebra.

A

True.

Comparing all pairs of tuples takes O(n^2) time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the time complexity for a better way to do a natural join or equijoin?

A

O(m + 2n log n).

This method involves sorting both tables by the join attributes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the purpose of division in relational algebra?

A

To find values related to all values in another set.

Example: R(A,B) = students and courses passed; S(B) = required courses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What set of operations is considered complete in relational algebra?

A

{σ, π, ∪, −, ×}.

Any other operations can be expressed as sequences from this set.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are aggregate functions in relational algebra?

A

Functions that go beyond basic operations, such as sum, average, maximum, minimum, and count.

Aggregate functions are used for summarizing data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is a limitation of relational algebra regarding recursive closure?

A

It does not inherently support hierarchical relationships.

Example: employees supervising each other in a circle.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the symbol for Union in set operations?

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What does the Union operation do?

A

Combine two sets by including all elements from both sets without duplicates.

20
Q

What is the symbol for Intersection in set operations?

21
Q

What does the Intersection operation find?

A

Common elements between two sets.

22
Q

What is the symbol for Difference in set operations?

23
Q

What does the Difference operation identify?

A

Elements that are in one set but not in the other.

24
Q

What is the symbol for Cartesian product in set operations?

25
What does the Cartesian product operation do?
Combine two sets by pairing each element from the first set with each element from the second set.
26
How is the Cartesian product of sets A and B represented?
AxB = {(1,x), (1,y), (2,x), (2,y)}
27
What is Projection π in relational databases?
Select specific columns from a table to display ## Footnote πx(r) = {t[X] | t ∈ r} means 'for every row t in table r, create a new row with only the columns in X'. X is a subset of the full set of attributes R.
28
What does σ represent in relational databases?
Filter rows from a table based on a condition ## Footnote σC(R) means 'from relation (table) R, select the rows that satisfy condition C'. C can be any condition: =, >, <, ≤, ≥, ≠, ∧, ∨, ¬.
29
What does the Join operation ▷◁ do in relational databases?
Combine two tables based on a common column (typically key) to create new table ## Footnote In a join, a row from R1 can match with more than one row in R2, and vice versa. Each match will be produced in the result.
30
What happens in a projection π when selected columns have identical rows?
One is hidden to avoid duplicates for the display.
31
What is a unary operation in the context of relational databases?
An operation that works on one table (e.g., selection, projection).
32
What does the symbol ∧ represent in relational database conditions?
'and'
33
What does the symbol ∨ represent in relational database conditions?
'or'
34
What does the symbol ¬ represent in relational database conditions?
'not'
35
Give an example of a selection operation in a relational database.
σName='Brian'∧HobbyName='Drinking'(HOBBY)
36
What operation combines every row from two relations R and S?
Cartesian Product (R x S) ## Footnote Results in a new table T that has all the columns from both R and S.
37
What is the time complexity for comparing all pairs of tuples in a join operation?
O(n^2) ## Footnote This makes joins the most expensive operation of relational algebra.
38
What does it mean for relations to have the same arity?
Same number of columns ## Footnote This is required for union, difference, and intersection operations.
39
What operation is used to find values related to all values in another set?
Division ## Footnote Example: Students who passed all required courses.
40
What type of join uses a filter between columns to determine which columns to join?
Equijoin (Θ-join) ## Footnote Example: R(B) < S(D) joins rows where R(B) is less than S(D).
41
What is a better way to perform a natural join or equijoin?
Sort both tables by the join attributes and merge ## Footnote This approach reduces the time complexity to O(m + 2n log n).
42
What are the components of the set of relational algebra operations?
σ, π, ∪, −, × ## Footnote This set is complete, meaning any other operations can be expressed using these.
43
What are aggregate functions in relational algebra?
Functions that go beyond basic operations ## Footnote Examples include sum, average, maximum, minimum, and count.
44
True or False: Intersection is required in relational algebra.
False ## Footnote Intersection can be expressed as a sequence of other operations.
45
What does recursive closure require that relational algebra does not inherently support?
A looping mechanism ## Footnote This is necessary to handle hierarchical relationships.
46
What is the operation to filter rows based on a condition in relational algebra?
Selection (σ) ## Footnote This operation extracts rows that satisfy a given condition.
47
What relational algebra operation retrieves specific columns from a relation?
Projection (π) ## Footnote This operation allows for selecting certain attributes from a relation.