RELATIONAL ALGEBRA Flashcards

1
Q

Define relational algebra

A

Relational algebra is a procedural query language which tasks instances of relations as input and yields instances of relations as output

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

Define relational calculus

A

Relational Calculus is a non-procedural query language ie it tells what to do but never explains how to do it

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

What are the differences between relational algebra and relational calculus?

A
  1. Relaional algebra is a procedural language while RC is a declarative language
  2. RA states how to obtain the result while RC states what result we have to obtain
  3. RA describes the order in which operations have to be performed while RC does not specify the order of operations
  4. RA is not domain dependent (data types allowed- domain) while relational Calculus ca be domain dependent
  5. RA is close to a programming language while RC is closer to natural language
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Explain the projection operation And give its syntax

A

Returns columns from relation.
π (name-of-column) name-or relation

*Check Liban’s notes for syntax

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

Explain the select operation And give its syntax

A

Selects a subset of rows from relation.

*Check Liban’s notes for syntax

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

Explain the union relation And give its syntax

A

Tuples in reln. 1 and in reln. 2.

*Check Liban’s notes for syntax

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

Explain set difference And give its syntax

A

Tuples in reln. 1, but not in reln. 2.

*Check Liban’s notes for syntax

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

Explain Cartesian product And give its syntax

A

Allows us to combine two relations.

*Check Liban’s notes for syntax

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

What is union compatibility?

A

Same number of fields.
‘Corresponding’ fields have the same data type.

*This condition is necessary for union, set difference and intersection operations

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

Explain the rename operation And give its syntax

A

If renaming table don’t put it in brackets if renaming columns place them in brackets Eg
ρ pro(A,B) (Project) -Query to rename the table name Project to Pro and its attributes to A B

*Check Liban’s notes for syntax

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

Describe what a join is and give its different types

A
Can be defined as cross-product followed by selection
and projection.
• We have several variants of join.
✓ Condition joins
✓ Equijoin
✓ Natural join
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Describe the theta/ condition join And give its syntax

A

combines two relations based on specified condition(s)

*see Liban’s notes for syntax

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

Describe the equijoin And give its syntax

A

A special case of condition join where the condition c
contains only equalities.

*Result schema similar to cross-product, but only one copy of fields for which equality is specified. *Check notes for syntax

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

Describe the natural join And give its syntax

A

Equijoin on all common fields

*Check Liban’s notes for syntax

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