ics321-20091001-relalgebra

# ics321-20091001-relalgebra - ICS 321 Fall 2009 Relational...

This preview shows pages 1–7. Sign up to view the full content.

ICS 321 Fall 2009 Relational Algebra Asst. Prof. Lipyeow Lim University of Hawaii at Manoa 10/01/2009 1 Lipyeow Lim -- University of Hawaii at Manoa

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

View Full Document
Relational Query Languages Query languages : Allow manipulation and retrieval of data from a database. Relational model supports simple, powerful QLs: Strong formal foundation based on logic. Allows for much optimization. Query Languages != programming languages! QLs not expected to be “Turing complete”. QLs not intended to be used for complex calculations. QLs support easy, efficient access to large data sets. 10/01/2009 Lipyeow Lim -- University of Hawaii at Manoa 2
Formal Relational Query Languages Two mathematical Query Languages form the basis for “real” languages (e.g. SQL), and for implementation: Relational Algebra : More operational , very useful for representing execution plans. Relational Calculus : Lets users describe what they want, rather than how to compute it. ( Non- operational, declarative .) 10/01/2009 Lipyeow Lim -- University of Hawaii at Manoa 3

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

View Full Document
Preliminaries A query is applied to relation instances , and the result of a query is also a relation instance. Schemas of input relations for a query are fixed (but query will run regardless of instance!) The schema for the result of a given query is also fixed! Determined by definition of query language constructs. Positional vs. named-field notation: Positional notation easier for formal definitions, named-field notation more readable. Both used in SQL 10/01/2009 Lipyeow Lim -- University of Hawaii at Manoa 4
Example Relational Instances “Sailors” and “Reserves” relations for our examples. We’ll use positional or named field notation, assume that names of fields in query results are `inherited’ from names of fields in query input relations sid bid day 22 101 10/10/96 58 103 11/12/96 10/01/2009 Lipyeow Lim -- University of Hawaii at Manoa 5 sid sname rating age 22 Dustin 7 45.0 31 Lubber 8 55.5 58 Rusty 10 35.0 R1 S1 S2 sid sname rating age 28 Yuppy 9 35.0 31 Lubber 8 55.5 44 Guppy 5 35.0 58 Rusty 10 35.0

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

View Full Document
Relational Algebra Basic operations: Selection ( ς ) Selects a subset of rows from relation. Projection ( π ) Deletes unwanted columns from relation. Cross-product ( × ) Allows us to combine two relations. Set-difference ( ) Tuples in reln. 1, but not in reln. 2. Union
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 24

ics321-20091001-relalgebra - ICS 321 Fall 2009 Relational...

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

View Full Document
Ask a homework question - tutors are online