aboutsummaryrefslogtreecommitdiff
path: root/semestre 4/db/td/2- Schéma relationnelle.md
blob: 7a397ca59e4a3565d74c07e9a43653a122309c25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
tags:
  - sorbonne
  - informatique
  - db
  - td
semestre: 4
---
## Exo 5
```
Bateau(_immat_, nom, longueur, skippeur*)
Marin(_nom_)
Skipper(_nom*_)
Equipiers(_nom*_, profession)
Sponsor(_nom_)
Epreuves(_jour_, start, end)
Classement(_immat*_, _jour*_, position)
Engagé(_immat*_, _equipier*_, _jour*_)
Finance(_nom*_, _sponsor*_, _immat*_, montant)
```
## Exo 6
```
Drug(_code_, libelle, indication, posologie)
Consultation(_num_, date, medecin*, patient*)
Med(_matricule_, nom)
Patient(_num-ss_, nom)
Prescrit(nb-jours, _drug*_, _consult*_)
```
## Exo 7
```
Film(_titre_, real*, entrees)
Real(_nom_, prenom)
Acteur(_nom_, prenom, date-naissance, adresse)
Joue(_film*_, _acteur*_, cachets)
```

```sql
CREATE DATABASE IF NOT EXISTS reals(
	nom TEXT PRIMARY KEY,
	prenom TEXT
);

CREATE DATABASE IF NOT EXISTS acteurs(
	nom TEXT PRIMARY KEY,
	prenom TEXT,
	age INTEGER,
	adresse TEXT
);

CREATE DATABASE IF NOT EXISTS film(
	title TEXT PRIMARY KEY,
	real_name TEXT,
	entrees INTEGER,
	FOREIGN KEY(real_name) REFERENCES reals(nom)
);

CREATE DATABSE IF NOT EXISTS joue(
	film_title TEXT,
	film_acteur TEXT,
	cachet INTEGER,
	FOREIGN KEY(film_title) REFERENCES film(title),
	FOREIGN KEY(film_acteur) REFERENCES acteurs(nom),
	PRIMARY KEY (film_title, film_acteur)
);
```
## Exo 8
```
Ouvrage(_ref_, titre, editeur)
Revue(_ouvrage*_, period)
NumeroRevu(_numero_, date, revue*)
Livre(_ouvrage*_)
Abonne(_code_, nom, prenom, date-abo)
Calendrier(_date-pret_)
Pret(_ouvrage*_, _abonne*_, date)
HistPret(_ouvrage*_, _abonne*_, _calendrier*_)
```
## Exo 9
```
Personnel(_id_, nom, prenom, bureau)
Enseignant(_personnel*_)
Chercheur(_personnel*_, lab*)
EnseignantChercheur(_enseignant*_, _chercheur*_)
Reunion(_id_, date, start, end, salle)
Participe(_personnel*_, _reunion*_)
Matiere(_id_, annee)
Cours(_salle_, begin, finish, day, start, end, matiere*, enseignant*)
Lab(_nom_, secretariat)
Mission(_chercheur*_, begin, finish, lieu)
```
## Exo 10

(j'ai pas fait les 11 et 12 par flemme)