14-12-2012, 04:53 PM
Relational Query Languages
Relational Query.pptx (Size: 439.2 KB / Downloads: 22)
Languages for describing queries on a relational database
Structured Query Language (SQL)
Predominant application-level query language
Declarative
Relational Algebra
Intermediate language used within DBMS
Procedural
What is an Algebra?
A language based on operators and a domain of values
Operators map values taken from the domain into other domain values
Hence, an expression involving operators and arguments produces a value in the domain
When the domain is a set of all relations (and the operators are as described later), we get the relational algebra
We refer to the expression as a query and the value produced as the query result
Relational Algebra
Domain: set of relations
Basic operators: select, project, union, set difference, Cartesian product
Derived operators: set intersection, division, join
Procedural: Relational expression specifies query by describing an algorithm (the sequence in which operators are applied) for determining the result of an expression
Union Compatible Relations
Two relations are union compatible if
Both have same number of columns
Names of attributes are the same in both
Attributes with the same name in both relations have the same domain
Union compatible relations can be combined using union, intersection, and set difference