Relational Algebra and SQL - Cornell University
Relational Algebra and SQL
Johannes Gehrke johannes@cs.cornell.edu
Slides from Database Management Systems, 3rd Edition,
Ramakrishnan and Gehrke.
Database Management Systems, R. Ramakrishnan and J. Gehrke
1
Relational Query Languages
v Query languages: Allow manipulation and retrieval of data from a database.
v Relational model supports simple, powerful QLs:
? Strong formal foundation based on logic. ? Allows for much optimization.
v 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.
Database Management Systems, R. Ramakrishnan and J. Gehrke
2
Formal Relational Query Languages
v 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. (Nonoperational, declarative.)
Database Management Systems, R. Ramakrishnan and J. Gehrke
3
Preliminaries
v 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.
v Positional vs. named-field notation:
? Positional notation easier for formal definitions, named-field notation more readable.
? Both used in SQL
Database Management Systems, R. Ramakrishnan and J. Gehrke
4
R1 sid bid day
Example Instances 22 101 10/10/96
58 103 11/12/96
v "Sailors" and "Reserves" relations for our examples.
S1 sid
sname
rating
age
v We'll use positional or
22 dustin 7 45.0
named field notation,
31 lubber 8 55.5
assume that names of fields in query results are
58 rusty
10 35.0
`inherited' from names of fields in query input relations.
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
Database Management Systems, R. Ramakrishnan and J. Gehrke
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- big data analytics building blocks simple data storage
- lecture 25 database notes cmu statistics
- introduction to sql
- introduction to relational database
- statistical computing 36 350 databases i
- the dangers and complexities of sqlite benchmarking
- relational algebra and sql cornell university
- how to use sqlite with r
- cs 564 database management systems university of
Related searches
- cornell university data analytics program
- cornell university data analytics certificate
- cornell university business analytics
- cornell university business
- cornell university johnson business school
- cornell university college of business
- cornell university college report
- cornell university reputation
- cornell university data analytics
- cornell university dyson business school
- cornell university johnson
- cornell university johnson school