




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Relational Algebra. 6-6. Example Database (3). • RESULTS: one row for each submitted solution to an exercise. SID: Student who wrote the solution.
Typology: Lecture notes
1 / 117
This page cannot be seen from the preview
Don't miss anything!





























































































References:
After completing this chapter, you should be able to:
101 Ann Smith · · · 102 Michael Jones (null) 103 Richard Turner · · · 104 Maria Brown · · ·
EXERCISES CAT ENO TOPIC MAXPT H 1 Rel. Algeb. 10 H 2 SQL 10 M 1 SQL 14
SID: “Student ID” (primary key). FIRST, LAST: First and last name. EMAIL: Email address (can be null).
CAT: Exercise category (key together with ENO). E.g. ’H’: homework, ’M’: midterm exam, ’F’: final exam. ENO: Exercise number (within category). TOPIC: Topic of the exercise. MAXPT: Max. no. of points (How many points is it worth?).
set.
operations + and ∗ forms an algebra.
of all finite relations.
This is natural since relations are sets.
is again a relation, it can be input for another re- lational algebra operation. And so on, until the query result is computed (again a relation). The relational algebra is so simple because the relational model has only a single construct: The relation.
Minor Data Model Differences to SQL:
a relation, namely those which satisfy the conditi- on ϕ. Selection acts like a filter on the input set. σ is the greek letter sigma, ϕ is the greek letter phi. All textbooks use σ for selection, but ϕ is not standard. In ASCII, write e.g. SELECTcondition.
〈Term〉 〈Comparison-Operator〉 〈Term〉
(1) Create new temporary relation T ; (2) foreach tuple t from input relation R do (3) Evaluate condition ϕ for tuple t; (4) if true then (5) insert t into T ; (6) fi (7) od; (8) return T ;
ding each tuple of the input relation.
WHERE ϕ
jection” corresponds to the SELECT-clause in SQL. This can be slightly confusing.