This commit is contained in:
David Schirrmeister 2025-04-14 15:53:40 +02:00
parent 2036b2ce1a
commit e1818f834c
10 changed files with 63 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -153,4 +153,66 @@
![image_656.png](image_656.png)
#### Minimalkardinalität 1 → "Richtung 1"
#### Minimalkardinalität 1 → "Richtung 1"
![image_669.png](image_669.png)
![image_670.png](image_670.png)
```sql
ABTEILUNGSNR INT4 not null,
constraint FK_MA_ZUGEH_ABT foreign key (ABTEILUNGSNR)
references ABTEILUNG (ABTEILUNGSNR)
ON delete restrict on update restrict
```
#### Minimalkardinalität 0 → "Richtung 1"
- nahezu identisch zu [1...1](#minimalkardinalit-t-1-richtung-1)
- hier möglichkeit für `Abteilungsnr = null`
```sql
ABTEILUNGSNR INT4 null,
constraint FK_MA_ZUGEH_ABT foreign key (ABTEILUNGSNR)
references ABTEILUNG (ABTEILUNGSNR)
ON delete restrict on update restrict
```
#### Minimalkardinalität 0 bzw. 1 → Vielfalt
- 1. NF erlaubt es nicht, da Collection-Datentypen nicht erlaubt sind
- vor allem für Fremdschlüsselspalten
- wenn 0/1..* → allein über constraints nicht implementierbar
- kann man dann über Trigger machen (Kapitel 6)
→ Umwandeln in [n:m Assoziation](#umwandlungsregel-n-m-assoziation)
#### Umwandlungsregel n:m Assoziation
##### 1..*:1..* Assoziation {id="1-1-assoziation_1"}
![image_672.png](image_672.png)
- Einfügen einer neuen Tabelle, welche aus den anderen beiden Tabellen jeweils einen Fremdschlüssel hat
- Primärschlüssel jeweils als `concatenated key` einfügen
- dann muss er immer mit drin sein
- dadurch kann jede Zeile aus beiden Tabellen auf mehrere aus der anderen verlinken
- _geht dann auch mit >2 Tabellen_
##### 0..*:0..* Assoziation
- Vier Alternativen
1. FK bei R1
2. FK bei R2
3. FK bei R1 und R2
4. m:n Relation einfügen wie [hier](#umwandlungsregel-n-m-assoziation)
- Hauptnavigationsrichtung der Anwendung entscheidet
##### Assoziation mit sich selbst (Stückliste)
> Selbstreferenzierende n:m Assoziation
###### Beispiel Stückliste Fahrrad
![image_673.png](image_673.png)
![image_674.png](image_674.png)
- man verfährt wie bei der n:m Beziehung durch Einfügen einer Assoziationsklasse
- ![image_675.png](image_675.png)
- um Fahrradstückliste zu implementieren sind also 2 Tabellen notwendig:
- | Teileliste | Stückliste |
|---------------------------------|---------------------------------|
| ![image_676.png](image_676.png) | ![image_677.png](image_677.png) |
### Abbildung Vererbungshierarchien