Database 1
Data Manipulation
- Prof. dr. Paul M.E. De Bra
- Dept. of Computer Science
- Eindhoven Univ. of Technology
Architecture of database applications
Types of query languages
- Procedural:
- The user specifies which operations to apply on the database in order to produce the answer to a question. (looks like programming)
- Declarative:
- The user specifies which data are needed to answer the question but not how to obtain these data. (looks like logic formulas)
Relational Algebra
- It is an “algebra”: it lets you compute with tables.
- The operations are “fundamental” database operators: projection, selection, cartesian product, union, difference, renaming. (like ,,, for numbers)
- Translating natural language to the relational algebra requires a lot of insight into how to choose a suitable combination of operations.
- Reading a query is like arithmetic: understanding the result of a combination of operations.
Instance Expressions
- The relational algebra = calculating with relation instance expressions
- A table (instance) is an instance expression
- The result of an ra operation on instance expressions is an instance expression
- This is just like with variables and expressions in programming languages
Example database
The tuple calculus
- In databases we use a declarative query language:
- looks “like” logic and set expressions
- in databases we use a different syntax
- we translate natural language to tuple calculus expressions and back
SQL (Structured Query Language)
- The “real-world” query language
- mostly declarative like the tuple calculus
- has some “simplifications”, like not making a distinction between a singleton set and a single value
- has some “complications”, like using bags instead of sets, dealing with missing information through null values, and using a three-valued logic
- SQL is difficult to understand and use correctly but it is used a lot and we must learn it
Preparation for labsession 1
- Study chapter 3 of the database book, up to and including section 3.2.2.
- 3.1 explains the basics of the relational database model. It briefly recalls the relationship between the E-R model and the relational model.
- 3.2 describes the relational algebra. The operators are introduced and described in 3.2.1, and relational algebra expressions are defined in 3.2.2.