Relational algebra Flashcards

1
Q

Name 2 unary operations in relational algebra

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

Explain the unary operation projection

A

Symbol: pi
Operation: selects attributes removing duplicate tuples
Example: pi attribute1, attribute2, … attributeN (tableName)
SQL equivalent: SELECT attribute1, attribute2, …, attributeN FROM (tableName)

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

Explain unary operation selection

A

Symbol: σ
Operation: Selects tuples by predicate
Example: σ predicate (TableName)
SQL equivalent: WHERE predicate (FROM tableName)

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

Name and describe the 5 binary operations in relational algebra

A

Cartesian product
Union
Intersection
Difference
Join

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

Explain the binary operation cartestian product

A

Symbol: x
Operation: Shows a concatenation of all tuples in two relations
Example: A x B
SQL equivalent: CROSS join

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

Explain the binary operation union

A

Symbol: U
Operation: Gets all the tuples in either one or both relations
Example: Relation U Relation
SQL equivalent: UNION

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

Explain the binary operation intersection

A

Symbol: ⋂
Operation: Gets all the tuples present in BOTH relations
Example: Relation ⋂ Relation
SQL equivalent: INTERSECT

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

Explain the binary operation difference

A

Symbol: -
Operation: Gets all the tuples in one set but NOT in another
Example: Relation - Relation
SQL equivalent: EXCEPT/MINUS

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

Explain the binary operation join?

A

Symbol: ⋈
Operation: Joins two relations over all common attributes x
Example: Relation ⋈ Relation
SQL equivalent: INNER JOIN

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

What does it mean if two sets are union compatible?

A
  • There is the same number of attributes
  • Attributes have the same domain
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the set equivalence to A ⋂ B?

A

A - (A - B)

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

What is the difference between relational algebra and SQL?

A

Relational algebra is the formal language
- Theoretical foundations of SQL
SQL is the ‘real language’
- Actually use it in databases

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

What are the fundamental relational algebra operations?

A

Selection
Projection
Cartesian product
Union
Set difference

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

What are NOT the fundamental relational algebra operations?

A

Join
Intersection

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

What makes an operation fundamental?

A

If it cannot be made up of anything other than itself

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

What happens with duplicate tuples in relational algebra?

A

They are eliminated