Relational Algebra Flashcards

1
Q

What does the projection operation do, and what is the notation?

A

It returns a relation that only includes the attributes given in the projection.

E.G. π{l, k}R will project out the columns l and k from relation R.

Like a select query in SQL.

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

Write the notation to project CourseNo and Title from the following table, and calculate the result:

Course

CourseNo title year c1 aa 3 c2 bb 2 c3 cc 1

A

π{CourseNo, Title}Course

CourseNo Title c1 aa c2 bb c3 cc

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

What is the Cartesian Product operation, and how is it written?

A

Returns all combinations of rows from the two supplied relations

RelationA ⊗ RelationB

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

What do you do if R1 and R2 have a column of the same name, and you want to calculate the cartesian product?

A

In the result rename the conflicting columns to R1.Name and R2.Name

If you are cartesianing the same table, it becomes R1.Name and R1′.Name

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

What is the selection operation and how is it written?

A

Selects rows from a relation if they meet the predicate.

Notation:

σP(R)

i.e. select all rows from R according to predicate P

Example:

σTitle=bb(Course)

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

How do you combine projection and selection?

A

π{Attribute}σPredicate(Relation)

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

What is natural join, and how is it written?

A

Combines all the attributes in R and S for each row identified by a common attribute a

i.e. if a is the same in both relations, the row is made

example:

R⋈S = π{all attributes}σR.a=S.a(R⊗S)

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

How is Union handled in relational algebra?

A

Relations are considered to be sets of tuples

Must be of the same type

Input types: two set([l:A,k:b])

Output type: one set([l:A,k:b])

Any members in R1 or R2 will be in R1 U R2

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