1 CC301: Database Technology Lecture 1 Relational Algebra and SQL
2 Content 1 Models, Languages and their Use in databases 2 The Relational Algebra (RA) 3 Simulating RA operations in SQL
3 1.1 Relational and other data models Relational models (relational algebra, relational calculus) – most of the contemporary RDBMS are based on them Tree models (hierarchical, object-relational) – both legacy systems and new systems use them Object-oriented models (ODMG) – recent development, still not widely employed Note: XML native databases have some similarities with the hierarchical database systems (legacy systems), but they have more elaborated model and query languages, which are close to OQL (the standard query language of object- oriented databases)
4 1.2 Relational Languages and their Use D ata M anipulation L anguage (DML) Use: Populates, updates, and queries relational DB Example: relational algebra, SQL DML D ata D efinition L anguage (DDL) Use: Specifies the data structures and defines the relational schema Example: domain calculus, SQL DDL D ata C ontrol L anguage (DCL) Use: Specifies operation permissions, resource access discipline and user profiles Example: SQL DCL, LDAP Note: Contemporary relational languages often incorporate some object- relational features of the model – e.g. Oracle 8i SQL has types, Oracle 9i SQL has type inheritance
5 1.3 Can DB live without formal model? The answer is NO for several reasons: as we will see, SQL has ambiguities, while the relational algebra is unambiguous – so it can provide semantic interpretation for SQL Moreover, because of the same reason SQL cannot be executed directly, it needs to be translated into a realistic structure of operations first, which can be interpreted then Finally, if we want to control the execution of the SQL statements, we need to know how it works
6 2 The Relational Algebra Proposed by Codd in 1970 as a formal data model. Describes the relations and the operations to manipulate relations Relational operations in relational algebra transform either a single relation (unary operation), or a pair (binary operation) into another relation Can be also used to specify retrieval requests (queries). Query result is also in the form of a relation. Relational Operations: RESTRICT ( ) and PROJECT ( ) operations.
- Summer '19
- Relational model