This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 1 Database Systems I Relational Algebra CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 2 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model supports simple, powerful query languages: Strong formal foundation based on logic. High level, abstract formulation of queries. Easy to program. Allows the DBS to do much optimization. DBS can choose, e.g., most efficient sorting algorithm or the order of basic operations. CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 3 Relational Query Languages 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. E.g., in a QL cannot determine whether the number of tuples of a table is even or odd, create a visualization of the results of a query, ask the user for additional input. CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 4 Formal Query Languages Two mathematical query languages form the basis for “real” languages (e.g. SQL), and for implementation: Relational Algebra (RA) : More procedural , very useful for representing execution plans, relatively close to SQL. Relational Calculus (RC) : Lets users describe what they want, rather than how to compute it. ( Non procedural, declarative .) Understanding these formal query languages is important for understanding SQL and query processing. CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 5 Relational Algebra An algebra consists of operators and operands . Operands can be either variables or constants. In the algebra of arithmetic, atomic operands are variables such as x or y and constants such as 15. Operators are the usual arithmetic operators such as +, , *. Expressions are formed by applying operators to atomic operands or other expressions. For example, 15 x + 15 (x + 15) * y CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 6 Relational Algebra Algebraic expressions can be reordered according to commutativity or associativity laws without changing their resulting value. E.g., 15 + 20 = 20 + 15 (x * y) * z = x * (y * z) Parentheses group operators and define precedence of operators, e.g....
View
Full Document
 Spring '09
 KeWang
 Relational model, Martin Ester

Click to edit the document details