Lecture 8 - Relational algebra - annotated

Lecture 8 - Relational algebra - annotated - Section...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Relational algebra INFO/COM S 230: Intermediate Web Design and Programming Section Friday’s section (in part): How to install and configure Apache, PHP, and MySQL. You may want to bring your laptop. Brief review of relational DBs Last time we introduced relations and relational DBs. 201 mins. 2003 The Return of the King 113 mins. 2002 Chicago 2004 2001 2000 Year Length Title 132 mins. Million Dollar Baby 135 mins. A Beautiful Mind 155 mins. Gladiator Year Title Name 2004 Million Dollar Baby Hillary Swank 2003 Return of the King Viggo Mortensen 2001 A Beautiful Mind Russel Crowe 2000 Gladiator Russel Crowe Getting info out of a DB Today: Given a relational DB, how do we extract information that we want? E.g. What sort of questions (queries) might we ask of a movie DB? Algebra “Regular” algebra: variables (e.g. x, y, z) and constants (e.g. 1, 2, 5) combined via operators (e.g. +, -, *) (3 x + 2) * 4 z If all constants and variables stand for integers, and have operators +, -, *, the result of applying operators will always be a Easy PDF Creator is professional software to create PDF. If you wish to remove this line, buy it now.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Relational algebra Relational algebra also has variables (standing for relations), constants (relations from our DB), and operators. The result of applying any number of operators will always be a Operators To finish defining the relational algebra, must define the operators we can use. 1. Select ( σ ) 2. Project ( π ) 3. Union ( [ ) 4. Difference ( — ) 5. Intersection ( Å ) 6. Cartesian Product ( £ ) and Join ( ! ) Select operator Select The operator σ P applied to a relation returns all tuples for which the predicate (or condition ) P is true. E.g. σ Length > 150 applied to the Movie relation returns 201 mins. 2003 The Return of the King 113 mins. 2002 Chicago 2004 2001 2000 Year Length Title 132 mins. Million Dollar Baby 135 mins. A Beautiful Mind 155 mins. Gladiator Selection predicates What kind of predicates can we use? Use the same kind we can express in PHP conditionals: e.g. • Length > 150 • Length <= 150 • Length == 150 • Length != 150 King” σ (Movies) returns 201 mins. 2003 The Return of the King 113 mins. 2002 Chicago 2004 2001 2000 Year Length Title 132 mins. Million Dollar Baby 135 mins. A Beautiful Mind
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

Lecture 8 - Relational algebra - annotated - Section...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online