Relational Algebra Flashcards

databases and relations

1
Q

σ age > 30 (Employees)

A

Selection – Filters rows where the condition holds true. Returns all employees older than 30.

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

π name, age (Employees)

A

Projection – Selects specific columns (name and age) from the relation, removing duplicates.

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

Employees ∪ Managers

A

Union – Combines all unique tuples from both relations. Relations must have the same schema.

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

Employees ∩ Managers

A

Intersection – Returns tuples that exist in both relations. Requires union-compatible relations.

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

Employees − Retired

A

Set Difference – Returns tuples in Employees that are not in Retired.

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

Employees × Departments

A

Cartesian Product – Combines every row in Employees with every row in Departments.

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

Employees ⨝ dept_id = id (Departments)

A

Theta Join – Joins relations where the condition (here, dept_id = id) is true.

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

Employees ⨝ dept_id = id (Departments)

A

Equijoin – A theta join where the condition is equality.

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

Employees ⨝ Departments

A

Natural Join – Joins using all common attribute names, removing duplicate columns.

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

ρ E (Employees)

A

Rename – Renames a relation or its attributes. Here, Employees is renamed to E.

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

Projects ÷ RequiredSkills

A

Division – Returns projects that require all the skills listed in RequiredSkills.

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

Employees ⟕ Departments

A

Left Outer Join – Returns all rows from Employees, and the matched rows from Departments. Unmatched rows in Departments result in NULLs.

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

Employees ⟖ Departments

A

Right Outer Join – Returns all rows from Departments, and the matched rows from Employees. Unmatched rows in Employees result in NULLs.

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

Employees ⟗ Departments

A

Full Outer Join – Returns all rows when there is a match in either Employees or Departments. Unmatched rows result in NULLs on the side lacking a match.

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

Employees ⋉ Departments

A

Semijoin (Left) – Returns rows from Employees that have at least one matching row in Departments, based on the join condition, but does not include columns from Departments.

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

Employees ⋊ Departments

A

Semijoin (Right) – Returns rows from Departments that have at least one matching row in Employees, based on the join condition, but does not include columns from Employees.

17
Q

Employees ▷ Departments

A

Antijoin (Left) – Returns rows from Employees that do not have a matching row in Departments, based on the join condition.

18
Q

Departments ◁ Employees

A

Antijoin (Right) – Returns rows from Departments that do not have a matching row in Employees, based on the join condition.

19
Q

Employees ⋈ (σ dept_id = 10 (Departments))

A

Join with Selection – Joins Employees with Departments where dept_id is 10, combining join and selection operations.

20
Q

π name (σ age < 25 (Students))

A

Selection and Projection – Selects students younger than 25 and projects only their names.

21
Q

γ dept_id; avg(salary) → avg_salary (Employees)

A

Aggregation – Groups Employees by dept_id and calculates the average salary for each department.

22
Q

τ age (Employees)

A

Sorting (Order By) – Sorts the Employees relation by the age attribute in ascending order.