Flashcards
Flash Cards Relatioanl Algebra

Flashcards do conjunto (17)
- 1Basic of "RELATIONAL ALGEBRA" Operations

- 2Projection* Retains only attributes that are in the “projection list".
*The 1st query will produce a relation with only one column which is age. While the 2nd query produces a relation with two columns: sname and rating.
* The number of rows depends on the number of unique content. e.g. 1st query, 2 rows, 2nd query, 4 rows.
# Projection operator eliminates duplicates rows . - 3Selection# Selects rows that satisfy selection condition. Can also have multiple conditions.
# Result is a relation with same number of columns BUT probably lesser number of rows. - 4Union and Set-DifferenceAll of these operations take two input relations, which must be union compatible:
- Same number of fields.
- Corresponding’ fields have the same type. - 5Union
- 6Set Difference
- 7Cross-ProductResult schema has one field per field of R1 and R2, with field names `inherited’ if possible.
May have a naming conflict: Both R1 and R2 have a field with the same name. - 8Compound Operator: IntersectionIntersection takes two input relations, which must be union-compatible..
Q: How to express it using basic operators? - 9Intersection
- 10Compound Operator: JoinJoins are compound operators involving cross product, selection, and (sometimes) projection.
Most common type of join is a “natural join” (often just called “join”). R S conceptually is:
Compute R X S
Select rows where attributes that appear in both relations have equal values and domains.
Project all unique atttributes and one copy of each of the common ones. - 11Natural Join Example
- 12Outer JoinsLeft outer Join: each row in R1 will appear in results even if no matching row of R2 (null).
Right outer Join: each row in R2 will appear in results even if no matching row of R1 (null).
Full outer Join: each row in R1 will appear in even if no matching row of R2 and each row of R2 will appear even if no matching row of R1. - 13Compound Operator: DivisionExamples of Division A/B (AB)
- 14Aggregate FunctionsAggregation function takes a collection of values and returns a single value as a result.
avg: average value
min: minimum value
max: maximum
value sum: sum of values
count: number of values - 15Aggregate OperationsAggregate operation in relational algebra.
G1, G2, …, Gn ℱ F1( A1), F2( A2),…, Fn( An) (E)
E is any relational-algebra expression.
G1, G2 …, Gn is a list of attributes on which to group (can be empty).
Each Fi is an aggregate function.
Each Ai is an attribute name - 16Aggregate Operation – Example
- 17Assignment OperationThe assignment operation () provides a convenient way to express complex queries.
*Write query as a sequential program consisting of a series of assignments followed by an expression whose value is displayed as a result of the query.
*Assignment must always be made to a temporary relation variable.
Informações
- Descrição
- Explanation more about What is Relational Algebra?
- Criado por
- nurhidayah.mazni
- Visualizações
- 181
- Tags
- Avaliação