sync: 2026-10-07 18:45
This commit is contained in:
1 parent
22c9707c2f
commit
e8a2fd8a78
5 files changed
+145
-10
No files matched your search
Vendored
+10
-8
@@ -4,21 +4,21 @@
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "1a4f02879bac55fe",
|
||||
"id": "7f4e886d29c37714",
|
||||
"type": "tabs",
|
||||
"children": [
|
||||
{
|
||||
"id": "3fb4ed0a135ef3a8",
|
||||
"id": "fdfa318f948163ac",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "DEV1.1/CM.md",
|
||||
"file": "BD/TD.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
},
|
||||
"icon": "lucide-file",
|
||||
"title": "CM"
|
||||
"title": "TD"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -189,20 +189,22 @@
|
||||
"bases:Créer une nouvelle base": false
|
||||
}
|
||||
},
|
||||
"active": "3fb4ed0a135ef3a8",
|
||||
"active": "fdfa318f948163ac",
|
||||
"lastOpenFiles": [
|
||||
"Pasted image 20261002121116.png",
|
||||
"BD/TD.md",
|
||||
"Pasted image 20261006141945.png",
|
||||
"SCR/SCR 1.1/image.png",
|
||||
"SCR/SCR 1.1/CM-SCR.1.1_Access_Perm.pdf",
|
||||
"SCR/SCR 1.1/TD.md",
|
||||
"BD/BD 1.1.md",
|
||||
"DEV1.1/CM.md",
|
||||
"Pasted image 20261002121116.png",
|
||||
"BD/BD 1.1.md",
|
||||
"DEV1.1/TP/README.md",
|
||||
"BD",
|
||||
"2026-09-20.md",
|
||||
"Sans titre.base",
|
||||
"Sans titre.canvas",
|
||||
"SCR/README.md",
|
||||
"SCR/SCR 1.1/CM-SCR.1.1_Access_Perm.pdf",
|
||||
"DEV1.1/CM_1.1.md"
|
||||
]
|
||||
}
|
||||
@@ -165,4 +165,137 @@ SELECT (NumP,NomP) FROM Pieces WHERE ClrP = 'rouge' AND PdsP < 20;
|
||||
7:
|
||||
```sql
|
||||
SELECT (NumF) FROM Livraison WHERE NumP = 2 AND Qtte > 10;
|
||||
```
|
||||
```
|
||||
|
||||
# TD3
|
||||
|
||||
## exercice 2
|
||||
|
||||
R1
|
||||
|
||||
| NumVoiture | TypeVoiture | Couleur | Numpropriétaire | Puissance |
|
||||
| ---------- | ----------- | ------- | --------------- | --------- |
|
||||
| 5 TX 77 | Renault 25 | bleue | 3 | 9 |
|
||||
| 12 AV 75 | Citroën AX | rouge | 9 | 4 |
|
||||
| 7 BY 75 | Renault 5 | bleue | 17 | 5 |
|
||||
| 3 BZ 92 | Peugeot 206 | verte | 3 | 11 |
|
||||
|
||||
|
||||
> jointure naturelle : on ne garde qu'un exemplaire des attributs joints
|
||||
> Lorsque les attributs joints sont liés par une contrainte référentielle, il a dans la jointure autant de tuples que dans la source de la contrainte. De plus, la clef primaire de cette source peut servir de clef pour la table jointe
|
||||
|
||||
R2:
|
||||
|
||||
|
||||
| NumVoiture | Proprétaire.TypeVoiture | Couleur | NumPropriétaire | Modèle.TypeVoiture | Puissance |
|
||||
| ---------- | ----------------------- | ------- | --------------- | ------------------ | --------- |
|
||||
| 5 TX 77 | Renault 25 | bleue | 3 | Renault 25 | 9 |
|
||||
| 12 AV 75 | Citroën AX | rouge | 9 | Citroën AX | 4 |
|
||||
| 7 BY 75 | Renault 5 | bleue | 17 | Renault 5 | 5 |
|
||||
| 3 BZ 92 | Peugeot 206 | verte | 3 | Peugeot 206 | 11 |
|
||||
|
||||
>jointure ordinaire: on garde tous les attributs et on utilise les noms qualifiés pour les attributs ayant le même nom
|
||||
|
||||
|
||||
R3:
|
||||
![[Pasted image 20261006141945.png]]
|
||||
|
||||
>il n'y a aucun attribut en commun donc la jointure naturelle donne le même résultat qu'un produit cartésien
|
||||
|
||||
R4:
|
||||
|
||||
|
||||
| NumVoiture | TypeVoiture | Couleur | NumPropriétaire | NumPersonne | NomPersonne |
|
||||
| ---------- | ----------- | ------- | --------------- | ----------- | ----------- |
|
||||
| 5 TX 77 | Renault 25 | bleue | 3 | 3 | Pierre |
|
||||
| 12 AV 75 | Citroën AX | rouge | 9 | 9 | Luc |
|
||||
| 7 BY 75 | Renault 5 | bleue | 17 | 17 | Vincent |
|
||||
| 3 BZ 92 | Peugeot 206 | verte | 3 | 3 | Pierre |
|
||||
|
||||
>les jointures sont associatives et commutatives
|
||||
|
||||
| NumVoiture | TypeVoiture | Couleur | NumPropriétaire | NumPersonne | NomPersonne | Puissance |
|
||||
| ---------- | ----------- | ------- | --------------- | ----------- | ----------- | --------- |
|
||||
| 5 TX 77 | Renault 25 | bleue | 3 | 3 | Pierre | 9 |
|
||||
| 12 AV 75 | Citroën AX | rouge | 9 | 9 | Luc | 4 |
|
||||
| 7 BY 75 | Renault 5 | bleue | 17 | 17 | Vincent | 5 |
|
||||
| 3 BZ 92 | Peugeot 206 | verte | 3 | 3 | Pierre | 11 |
|
||||
|
||||
## exercice 2
|
||||
|
||||
### SQL89
|
||||
|
||||
R1:
|
||||
|
||||
```sql
|
||||
SELECT NumVoiture,Propriétaire.TypeVoiture, Couleur, NumPropriétire,Puissance FROM Propriétaire,Modèle WHERE Propriétaire.TypeVoiture = Modèle.TypeVoiture;
|
||||
```
|
||||
|
||||
(avec des alias)
|
||||
|
||||
```sql
|
||||
SELECT NumVoiture, P.TypeVoiture, Couleur, NumPropriétaire, Puissance
|
||||
FROM Propriétaire P, Modèle M
|
||||
WHERE P.TypeVoiture = M.TypeVoiture;
|
||||
```
|
||||
|
||||
```sql
|
||||
SELECT P.*, Puissance FROM Propriétaire P, Modèle M WHERE P.TypeVoiture = M.TypeVoiture;
|
||||
```
|
||||
|
||||
R4:
|
||||
|
||||
```sql
|
||||
SELECT * FROM Propriétaire, Personne WHERE NumPropriétaire = NumPersonne;
|
||||
```
|
||||
|
||||
R5:
|
||||
|
||||
```sql
|
||||
SELECT P.*, Puissance, Personne.* FROM Modèle M, Propriétaire P, Personne WHERE M.typeVoiture = P.TypeVoiture AND NumPropriétaire = NumPersonne;
|
||||
```
|
||||
|
||||
|
||||
|
||||
### SQL 92
|
||||
|
||||
R1:
|
||||
|
||||
avec Natural join
|
||||
|
||||
```sql
|
||||
SELECT * FROM Propriétaire NATURAL JOIN Modèle;
|
||||
```
|
||||
|
||||
avec JOIN et ON
|
||||
|
||||
```sql
|
||||
SELECT P.*, Puissance FROM Propriétaire P JOIN Modèle M ON P.TypeVoiture = M.TypeVoiture;
|
||||
```
|
||||
|
||||
avec JOIN ET USING
|
||||
|
||||
```sql
|
||||
SELECT * FROM Propriétaire P JOIN Modèle USING (TypeVoiture);
|
||||
```
|
||||
|
||||
>le JOIN .. USING est une sorte de NATURAL JOIN partiel
|
||||
- il utilise des attributes qui ont le même nom
|
||||
- il ne garde qu'un exemplaires des attributs joints
|
||||
|
||||
|
||||
|
||||
R4:
|
||||
|
||||
```sql
|
||||
SELECT * FROM Propriétaire JOIN Personne ON Propriétaire.NumPropriétaire = Personne.NumPersonne;
|
||||
```
|
||||
|
||||
R5:
|
||||
|
||||
```sql
|
||||
SELECT * FROM (Modèle NATURAL JOIN Propriétaire) JOIN Personne ON NumPropriétaire = NumPersonne;
|
||||
```
|
||||
|
||||
|
||||
|
||||
+1
-1
Submodule DEV1.1/TP updated: 3da0f6b44a...af5da0882d.
Binary file not shown.
|
After Width: | Height: | Size: 172 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Reference in new issue
Block a user