94 lines
3 KiB
Markdown
94 lines
3 KiB
Markdown
# Relationale Algebra
|
|
Die Rechen-Operationen, die vom Datenbank-Server ausgeführt werden, um Datensätze abzufragen, heisst Relationale Algebra.
|
|
Relationale Algebra ist im Prinzip die Computer-Sprache, zu der SQL-Abfragen vor der Ausführung umgewandelt werden.
|
|
|
|
## Operation Vereinigung $\cup$
|
|
Vereinigt zwei Relationen und entfernt alle Duplikate.
|
|
|
|
![](https://upload.wikimedia.org/wikipedia/commons/3/30/Venn0111.svg)
|
|
|
|
**_Beispiel:_**
|
|
**ActionActors:**
|
|
| FirstName | LastName | YearOfBirth |
|
|
| --------- | -------- | ----------- |
|
|
| Jackie | Chan | 1954 |
|
|
| Jason | Statham | 1967 |
|
|
| Vin | Diesel | 1967 |
|
|
|
|
**ComedyActors:**
|
|
| FirstName | LastName | YearOfBirth |
|
|
| --------- | -------- | ----------- |
|
|
| Jackie | Chan | 1954 |
|
|
| Ryan | Reynolds | 1976 |
|
|
| Jack | Black | 1969 |
|
|
|
|
**ActionActors $\cup$ ComedyActors:**
|
|
| FirstName | LastName | YearOfBirth |
|
|
| --------- | -------- | ----------- |
|
|
| Jackie | Chan | 1954 |
|
|
| Jason | Statham | 1967 |
|
|
| Vin | Diesel | 1967 |
|
|
| Ryan | Reynolds | 1976 |
|
|
| Jack | Black | 1969 |
|
|
|
|
> **_In Worten:_**
|
|
> Alle Schauspieler, die in Action- oder in Comedy-Filmen spielen.
|
|
|
|
|
|
## Operation Intersection $\cap$
|
|
Alle Elemente, die in beiden Relationen vorkommen.
|
|
|
|
![](https://upload.wikimedia.org/wikipedia/commons/9/99/Venn0001.svg)
|
|
|
|
**_Beispiel:_**
|
|
**ActionActors:**
|
|
| FirstName | LastName | YearOfBirth |
|
|
| --------- | -------- | ----------- |
|
|
| Jackie | Chan | 1954 |
|
|
| Jason | Statham | 1967 |
|
|
| Vin | Diesel | 1967 |
|
|
|
|
**ComedyActors:**
|
|
| FirstName | LastName | YearOfBirth |
|
|
| --------- | -------- | ----------- |
|
|
| Jackie | Chan | 1954 |
|
|
| Ryan | Reynolds | 1976 |
|
|
| Jack | Black | 1969 |
|
|
|
|
**ActionActors $\cap$ ComedyActors:**
|
|
| FirstName | LastName | YearOfBirth |
|
|
| --------- | -------- | ----------- |
|
|
| Jackie | Chan | 1954 |
|
|
|
|
> **_In Worten:_**
|
|
> Alle Schauspieler, die in Action- und in Comedy-Filmen spielen.
|
|
|
|
## Operator Differenz $\setminus$
|
|
Alle Elemente, die in der 1. Relation vorkommen und in der 2. Relation nicht vorkommen.
|
|
|
|
![](https://upload.wikimedia.org/wikipedia/commons/e/e6/Venn0100.svg)
|
|
|
|
**_Beispiel:_**
|
|
**ActionActors:**
|
|
| FirstName | LastName | YearOfBirth |
|
|
| --------- | -------- | ----------- |
|
|
| Jackie | Chan | 1954 |
|
|
| Jason | Statham | 1967 |
|
|
| Vin | Diesel | 1967 |
|
|
|
|
**ComedyActors:**
|
|
| FirstName | LastName | YearOfBirth |
|
|
| --------- | -------- | ----------- |
|
|
| Jackie | Chan | 1954 |
|
|
| Ryan | Reynolds | 1976 |
|
|
| Jack | Black | 1969 |
|
|
|
|
**ActionActors $\setminus$ ComedyActors:**
|
|
| FirstName | LastName | YearOfBirth |
|
|
| --------- | -------- | ----------- |
|
|
| Jason | Statham | 1967 |
|
|
| Vin | Diesel | 1967 |
|
|
|
|
|
|
> **_In Worten:_**
|
|
> Alle Schauspieler, die in Action-Filmen, aber in keinen Comedy-Filmen mitspielen.
|