This preview shows pages 1–8. Sign up to view the full content.
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 DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: INFS614001, GMU, Dr. Brodsky, Lecture 4 Relational Algebra Lecture 4 Professor Alex Brodsky INFS614  Database Management INFS614001, GMU, Dr. Brodsky, Lecture 4 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. INFS614001, GMU, Dr. Brodsky, Lecture 4 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 .) Understanding Algebra is key to understanding SQL, and query processing! INFS614001, GMU, Dr. Brodsky, Lecture 4 Algebra 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. INFS614001, GMU, Dr. Brodsky, Lecture 4 Example Instances sid sname rating age 22 dustin 7 45.0 31 lubber 8 55.5 58 rusty 10 35.0 sid sname rating age 28 yuppy 9 35.0 31 lubber 8 55.5 44 guppy 5 35.0 58 rusty 10 35.0 sid bid day 22 101 10/10/96 58 103 11/12/96 R1 S1 S2 Sailors and Reserves relations for our examples. INFS614001, GMU, Dr. Brodsky, Lecture 4 Algebra Operations Look what we want to get from the following table: sid sname rating age 28 yuppy 9 35.0 31 lubber 8 55.5 44 guppy 5 35.0 58 rusty 10 35.0 INFS614001, GMU, Dr. Brodsky, Lecture 4 Projection sname rating yuppy 9 lubber 8 guppy 5 rusty 10 sname rating S , ( ) 2 age 35.0 55.5 age S ( ) 2 Deletes attributes that are not in projection list . Schema of result contains exactly the fields in the projection list, with the same names that they had in the (only) input relation....
View
Full
Document
This note was uploaded on 01/20/2010 for the course CS 614 taught by Professor Jessica during the Fall '09 term at George Mason.
 Fall '09
 Jessica
 Databases

Click to edit the document details