• Aucun résultat trouvé

FormatPowerPoint97

N/A
N/A
Protected

Academic year: 2022

Partager "FormatPowerPoint97"

Copied!
35
0
0

Texte intégral

(1)

5 Introduction au modèle relationnel

5.1 Concepts de base

Domaine : ensemble de valeurs

Relation : ensemble de tuples

 SQL : multi-ensemble

noClient nomClient noTéléphone 10 Luc Sansom (999)999-9999 20 Dollard Tremblay (888)888-8888

30 Lin Bô (777)777-7777

40 Jean Leconte (666)666-6666 50 Hafedh Alaoui (555)555-5555 60 Marie Leconte (666)666-6666 70 Simon Lecoq (444)444-4419 80 Dollard Tremblay (333)333-3333

l i g n e / t u p l e

c o l o n n e / a t t r i b u t

t a b l e /

r e l a t i o n

(2)

suite

Deux facettes du concept de table

Schéma d'une table (table schema)

définition de son type (intention)

ex: Client(noClient, nomClient, noTéléphone)

Instance ou extension d'une table

état de la table

~ variable qui contient un ensemble de lignes

modifications d ’état

Schéma relationnel

– ensemble de schémas de tables

(3)

Instance de BD VentesPleinDeFoin

Table Commande

noCommande dateCommande noClient

1 01/ 06/ 2000 10

2 02/ 06/ 2000 20

3 02/ 06/ 2000 10

4 05/ 07/ 2000 10

5 09/ 07/ 2000 30

6 09/ 07/ 2000 20

7 15/ 07/ 2000 40

8 15/ 07/ 2000 40

Table LigneCommande noCommande noArticle quantité

1 10 10

1 70 5

1 90 1

2 40 2

2 95 3

3 20 1

4 40 1

4 50 1

5 70 3

5 10 5

5 20 5

6 10 5

6 40 1

7 50 1

7 95 2

8 20 3

Table

Article

noArticle description prixUnitaire quantitéEnStock 10 Cèdre en boule 10.99 10

20 Sapin 12.99 10

40 Epinette bleue 25.99 10

50 Chêne 22.99 10

60 Erable argenté 15.99 10

70 Herbe à puce 10.99 10

80 Poirier 26.99 10

81 Catalpa 25.99 10

Table DétailLivraison

noLivraison noCommande noArticle quantitéLivrée

100 1 10 7

100 1 70 5

101 1 10 3

102 2 40 2

102 2 95 1

100 3 20 1

103 1 90 1

104 4 40 1

105 5 70 2

Table Livraison noLivraison dateLivraison 100 3/ 06/ 2000 101 4/ 06/ 2000 102 4/ 06/ 2000 103 5/ 06/ 2000 104 7/ 07/ 2000 105 9/ 07/ 2000 Table Client

noClient nomClient noTéléphone 10 Luc Sansom (999)999-9999 20 Dollard Tremblay (888)888-8888

30 Lin Bô (777)777-7777

40 Jean Leconte (666)666-6666 50 Hafedh Alaoui (555)555-5555 60 Marie Leconte (666)666-6666 70 Simon Lecoq (444)444-4419 80 Dollard Tremblay (333)333-3333

(4)

5.2 Contraintes d'intégrité du modèle relationnel 5.2.1 Contrainte de domaine et de valeur non nulle

T(A 1 : D 1, A 2 : D 2 , …, A n : D n )

D i : domaine de A i

 Valeur nulle

– Comportement particulier

– Valeur inconnue

– Valeur non applicable

– ...

(5)

5.2.2 Clé primaire et contrainte d'entité

Clé unique (unique key)

ou superclé (superkey )

– identifiant

Clé candidate (candidate key)

– clé unique minimale

Clé primaire (primary key)

– sert de mécanisme de référence aux lignes de la table

Contrainte d'entité (entity constraint)

  clé primaire

– non nulle

(6)

5.2.3 Contrainte

d'intégrité référentielle

 Clé étrangère non nulle  clé primaire

noClient nomClient noTéléphone

10 Luc Sansom (999)999-9999

20 Dollard Tremblay (888)888-8888

30 Lin Bô (777)777-7777

40 Jean Leconte (666)666-6666 50 Hafedh Alaoui (555)555-5555 60 Marie Leconte (666)666-6666 70 Simon Lecoq (444)444-4419 80 Dollard Tremblay (333)333-3333 noCommande dateCommande noClient

1 01/ 06/ 2000 10

2 02/ 06/ 2000 20

3 02/ 06/ 2000 10

4 05/ 07/ 2000 10

5 09/ 07/ 2000 30

6 09/ 07/ 2000 20

7 15/ 07/ 2000 40

8 15/ 07/ 2000 40

T a b l e C o m m a n d e T a b l e C l ie n t

C lé é t r a n g è r e C lé p r im a ir e

(7)

Représentation UML

Commande

{Clé primaire : noCommande}

noCommande : INTEGER dateCommande : DATE noClient : INTEGER

<<Table>>

Client

{Clé primaire : noClient}

noClient : INTEGER nomClient : VARCHAR noTéléphone : VARCHAR

<<Table>>

LigneCommande

{Clé primaire : noCommande, noArticle}

noCommande : INTEGER noArticle : INTEGER quantité : INTEGER

<<Table>>

Article

{Clé primaire : noArticle}

noArticle : INTEGER description : VARCHAR prixUnitaire : DECIMAL quantitéEnStock : INTEGER

<<Table>>

Livraison

{Clé primaire : noLivraison}

noLivraison : INTEGER dateLivraison : DATE

<<Table>> DétailLivraison

{Clé primaire : noLivraison, noCommande, noArticle}

noLivraison : INTEGER noCommande : INTEGER noArticle : INTEGER quantitéLivrée : INTEGER

<<Table>>

(8)

Nom clé étrangère  nom clé primaire

 Etiquette de la relation de dépendance

numéroClient Client

{Clé primaire : noClient}

noClient : INTEGER nomClient : VARCHAR noTéléphone : VARCHAR

<<Table>>

Commande

{Clé primaire : noCommande}

noCommande : INTEGER dateCommande : DATE numéroClient : INTEGER

<<Table>>

(9)

5.3 Algèbre relationnelle

 Opérations de manipulation de données

 Entrée

– une table : opération unaire

– deux tables : opération binaire

 Sortie

– une table

– permet la composition

 Origine de SQL (« SQUARE de IBM, San Jose »)

(10)

5.3.1 Sélection ()

Table Article

noArticle description prixUnitaire quantitéEnStock

10 Cèdre en boule 10.99 10

20 Sapin 12.99 10

40 Epinette bleue 25.99 10

50 Chêne 22.99 10

60 Erable argenté 15.99 10

70 Herbe à puce 10.99 10

80 Poirier 26.99 10

81 Catalpa 25.99 10

90 Pommier 25.99 10

95 Génévrier 15.99 10

noArticle description prixUnitaire quantitéEnStock

60 Erable argenté 15.99 10

70 Herbe à puce 10.99 10

95 Génévrier 15.99 10

prixUnitaire < 20.00 ET noArticle > 30 (Article)

(11)

5.3.2 Projection ()

noClient, dateCommande (Commande)

Table Commande

noCommande dateCommande noClient

1 01/ 06/ 2000 10

2 02/ 06/ 2000 20

3 02/ 06/ 2000 10

4 05/ 07/ 2000 10

5 09/ 07/ 2000 30

6 09/ 07/ 2000 20

7 15/ 07/ 2000 40

8 15/ 07/ 2000 40

noClient dateCommande

10 01/ 06/ 2000

20 02/ 06/ 2000

10 02/ 06/ 2000

10 05/ 07/ 2000

30 09/ 07/ 2000

20 09/ 07/ 2000

40 15/ 07/ 2000

(12)

5.3.3 Expressions complexes

noClient, dateCommande ( dateCommande > 05/07/2000 Commande)

Table Commande

noCommande dateCommande noClient

1 01/ 06/ 2000 10

2 02/ 06/ 2000 20

3 02/ 06/ 2000 10

4 05/ 07/ 2000 10

5 09/ 07/ 2000 30

6 09/ 07/ 2000 20

7 15/ 07/ 2000 40

8 15/ 07/ 2000 40

noCommande dateCommande noClient

5 09/ 07/ 2000 30

6 09/ 07/ 2000 20

7 15/ 07/ 2000 40

8 15/ 07/ 2000 40

dateCommande > 05/07/2000 Commande

noClient dateCommande

30 09/ 07/ 2000

20 09/ 07/ 2000

40 15/ 07/ 2000

(13)

5.3.4 Produit cartésien ()

Table Commande

noCommande dateCommande noClient

1 01/ 06/ 2000 10

2 02/ 06/ 2000 20

3 02/ 06/ 2000 10

4 05/ 07/ 2000 10

5 09/ 07/ 2000 30

6 09/ 07/ 2000 20

7 15/ 07/ 2000 40

8 15/ 07/ 2000 40

Client  Commande

Client.noClient nomClient noTéléphone noCommande dateCommande Commande. noClient

10 Luc Sansom (999)999-9999 1 01/ 06/ 2000 10

10 Luc Sansom (999)999-9999 2 02/ 06/ 2000 20

10 Luc Sansom (999)999-9999 3 02/ 06/ 2000 10

10 Luc Sansom (999)999-9999 4 05/ 07/ 2000 10

10 Luc Sansom (999)999-9999 5 09/ 07/ 2000 30

10 Luc Sansom (999)999-9999 6 09/ 07/ 2000 20

10 Luc Sansom (999)999-9999 7 15/ 07/ 2000 40

10 Luc Sansom (999)999-9999 8 15/ 07/ 2000 40

20 Dollard Tremblay (888)888-8888 1 01/ 06/ 2000 10

20 Dollard Tremblay (888)888-8888 2 02/ 06/ 2000 20

20 Dollard Tremblay (888)888-8888 3 02/ 06/ 2000 10

...

Table Client

noClient nomClient noTéléphone 10 Luc Sansom (999)999-9999 20 Dollard Tremblay (888)888-8888

30 Lin Bô (777)777-7777

40 Jean Leconte (666)666-6666 50 Hafedh Alaoui (555)555-5555 60 Marie Leconte (666)666-6666 70 Simon Lecoq (444)444-4419 80 Dollard Tremblay (333)333-3333

(14)

Exemple. Produire les

informations au sujet des

Clients et de leurs Commandes Client  Commande

Client.noClient nomClient noTéléphone noCommande dateCommande Commande. noClient

10 Luc Sansom (999)999-9999 1 01/ 06/ 2000 10

10 Luc Sansom (999)999-9999 2 02/ 06/ 2000 20

10 Luc Sansom (999)999-9999 3 02/ 06/ 2000 10

10 Luc Sansom (999)999-9999 4 05/ 07/ 2000 10

10 Luc Sansom (999)999-9999 5 09/ 07/ 2000 30

10 Luc Sansom (999)999-9999 6 09/ 07/ 2000 20

10 Luc Sansom (999)999-9999 7 15/ 07/ 2000 40

10 Luc Sansom (999)999-9999 8 15/ 07/ 2000 40

20 Dollard Tremblay (888)888-8888 1 01/ 06/ 2000 10

20 Dollard Tremblay (888)888-8888 2 02/ 06/ 2000 20

20 Dollard Tremblay (888)888-8888 3 02/ 06/ 2000 10

… … … …

Client.noClient nomClient noTéléphone noCommande dateCommande Commande. noClient

10 Luc Sansom (999)999-9999 1 01/ 06/ 2000 10

10 Luc Sansom (999)999-9999 3 02/ 06/ 2000 10

10 Luc Sansom (999)999-9999 4 05/ 07/ 2000 10

20 Dollard Tremblay (888)888-8888 2 02/ 06/ 2000 20

20 Dollard Tremblay (888)888-8888 6 09/ 07/ 2000 20

30 Lin Bô (777)777-7777 5 09/ 07/ 2000 30

40 Jean Leconte (666)666-6666 7 15/ 07/ 2000 40

40 Jean Leconte (666)666-6666 8 15/ 07/ 2000 40

clé primaire = clé étrangère

Client.noClient = Commande.noClient (Client  Commande)

(15)

Exemple. Produire les

informations au sujet des

Clients et de leurs Commandes

Client.noClient = Commande . noClient ( ClientCommande )

Client.noClient nomClient noTéléphone noCommande dateCommande Commande. noClient

10 Luc Sansom (999)999-9999 1 01/ 06/ 2000 10

10 Luc Sansom (999)999-9999 3 02/ 06/ 2000 10

10 Luc Sansom (999)999-9999 4 05/ 07/ 2000 10

20 Dollard Tremblay (888)888-8888 2 02/ 06/ 2000 20

20 Dollard Tremblay (888)888-8888 6 09/ 07/ 2000 20

30 Ye San Le Sou (777)777-7777 5 09/ 07/ 2000 30

40 Jean Leconte (666)666-6666 7 15/ 07/ 2000 40

40 Jean Leconte (666)666-6666 8 15/ 07/ 2000 40

Client.noClient, nomClient, noTéléphone, noCommande, dateCommande (…))

Colonne redondante

Client.noClient nomClient noTéléphone noCommande dateCommande

10 Luc Sansom (999)999-9999 1 01/ 06/ 2000

10 Luc Sansom (999)999-9999 3 02/ 06/ 2000

10 Luc Sansom (999)999-9999 4 05/ 07/ 2000

20 Dollard Tremblay (888)888-8888 2 02/ 06/ 2000

20 Dollard Tremblay (888)888-8888 6 09/ 07/ 2000

30 Ye San Le Sou (777)777-7777 5 09/ 07/ 2000

40 Jean Leconte (666)666-6666 7 15/ 07/ 2000

40 Jean Leconte (666)666-6666 8 15/ 07/ 2000

(16)

5.3.5 Jointure naturelle (  )

noClient nomClient noTéléphone noCommande dateCommande

10 Luc Sansom (999)999-9999 1 01/ 06/ 2000

10 Luc Sansom (999)999-9999 3 02/ 06/ 2000

10 Luc Sansom (999)999-9999 4 05/ 07/ 2000

20 Dollard Tremblay (888)888-8888 2 02/ 06/ 2000

20 Dollard Tremblay (888)888-8888 6 09/ 07/ 2000

30 Lin Bô (777)777-7777 5 09/ 07/ 2000

40 Jean Leconte (666)666-6666 7 15/ 07/ 2000

40 Jean Leconte (666)666-6666 8 15/ 07/ 2000

Table Commande

noCommande dateCommande noClient

1 01/ 06/ 2000 10

2 02/ 06/ 2000 20

3 02/ 06/ 2000 10

4 05/ 07/ 2000 10

5 09/ 07/ 2000 30

6 09/ 07/ 2000 20

7 15/ 07/ 2000 40

8 15/ 07/ 2000 40

Client 

Commande

Colonnes communes : colonnes de jointure ou clé de jointure

Schéma : union des colonnes

Table Client

noClient nomClient noTéléphone 10 Luc Sansom (999)999-9999 20 Dollard Tremblay (888)888-8888

30 Lin Bô (777)777-7777

40 Jean Leconte (666)666-6666 50 Hafedh Alaoui (555)555-5555 60 Marie Leconte (666)666-6666 70 Simon Lecoq (444)444-4419 80 Dollard Tremblay (333)333-3333

(17)

Sélectionner les nomClient qui ont commandé au moins un plant d'herbe à puce

Commande

{Clé primaire : noCommande}

noCommande : INTEGER dateCommande : DATE noClient : INTEGER

<<Table>>

Client

{Clé primaire : noClient}

noClient : INTEGER nomClient : VARCHAR noTéléphone : VARCHAR

<<Table>>

LigneCommande

{Clé primaire : noCommande, noArticle}

noCommande : INTEGER noArticle : INTEGER quantité : INTEGER

<<Table>>

Article

{Clé primaire : noArticle}

noArticle : INTEGER description : VARCHAR prixUnitaire : DECIMAL quantitéEnStock : INTEGER

<<Table>>

Livraison

{Clé primaire : noLivraison}

noLivraison : INTEGER dateLivraison : DATE

<<Table>> DétailLivraison

{Clé primaire : noLivraison, noCommande, noArticle}

noLivraison : INTEGER noCommande : INTEGER noArticle : INTEGER quantitéLivrée : INTEGER

<<Table>>

(18)

Sélectionner les nomClient qui ont commandé au moins un plant

d'herbe à puce

Commande {Clé primaire : noCommande}

noCommande : INTEGER dateCommande : DATE noClient : INTEGER

<<Table>>

Client {Clé primaire : noClient}

noClient : INTEGER nomClient : VARCHAR noTéléphone : VARCHAR

<<Table>>

LigneCommande

{Clé primaire : noCommande, noArticle}

noCommande : INTEGER noArticle : INTEGER quantité : INTEGER

<<Table>>

Article {Clé primaire : noArticle}

noArticle : INTEGER description : VARCHAR prixUnitaire : DECIMAL quantitéEnStock : INTEGER

<<Table>>

Livraison {Clé primaire : noLivraison}

noLivraison : INTEGER dateLivraison : DATE

<<Table>> DétailLivraison

{Clé primaire : noLivraison, noCommande, noArticle}

noLivraison : INTEGER noCommande : INTEGER noArticle : INTEGER quantitéLivrée : INTEGER

<<Table>>

nomClient ( description = “Herbe à puce ”

(Client  Commande  LigneCommande 

Article))

(19)

Formulations équivalentes

  nomClient ( description = “Herbe à puce ” (Client 

Commande  LigneCommande  Article))

  nomClient (  description = “Herbe à puce ” (((Client  Commande)  LigneCommande)  Article))

  nomClient ( description = “Herbe à puce ” (((Client 

LigneCommande)  Commande)  Article))

 …

(20)

Quelques règles d ’équivalence

 Eclatement d'une sélection conjonctive (SE)

e1 ET e2

(T) = 

e1

(

e2

(T))

 Commutativité de la sélection (SC)

e1

(

e2

(T)) = 

e2

(

e1

(T))

 Elimination des projections en cascades (PE)

liste1

(

liste2

(T)) = 

liste1

(T)

 Commutativité de la jointure (JC)

T

1

 T

2

= T

1

 T

2

 Associativité de la jointure (JA)

T

1

 (T

2

 T

3

) = (T

1

 T

2

)  T

3

 Voir évaluation des requêtes

(21)

Représentation sous forme d ’arbre de l ’expression algébrique

nomClient

(

description = “Herbe à puce ”

(((Client  Commande)  LigneCommande)  Article))

C li e n t C o m m a n d e

L ig n e C o m m a n d e A r t i c l e

 d e s c r i p t i o n = « H e r b e à p u c e »

  n o m C l ie n t

(22)

Cas d ’une clé de jointure composée

LigneCommande  DétailLivraison

Table

LigneCommande

noCommande noArticle quantité

1 10

10

1 70 5

1 90 1

2 40 2

2 95 3

3 20 1

4 40 1

4 50 1

5 70 3

5 10 5

5 20 5

6 10 5

6 40 1

7 50 1

7 95 2

8 20 3

Table

DétailLivraison

noLivraison noCommande noArticle quantitéLivrée

100

1 10

7

100 1 70 5

101

1 10

3

102 2 40 2

102 2 95 1

100 3 20 1

103 1 90 1

104 4 40 1

105 5 70 2

noCommande noArticle quantité noLivraison quantitéLivrée

1 10 10 100 7

1 10 10 101 3

1 70 5 100 5

1 90 1 103 1

2 40 2 102 2

2 95 3 102 1

3 20 1 100 1

4 40 1 104 1

5 70 3 105 2

(23)

5.3.6 Opération renommer ()

 Quels sont les Clients qui ont le même numéro de téléphone?

Client2 (Client)

Client.noClient, Client2.noClient,

(

Client.noTéléphone = Client2.noTéléphone

(Client

 

Client2

(Client)))

Table Client

noClient nomClient noTéléphone 10 Luc Sansom (999)999-9999 20 Dollard Tremblay (888)888-8888

30 Lin Bô (777)777-7777

40 Jean Leconte (666)666-6666 50 Hafedh Alaoui (555)555-5555 60 Marie Leconte (666)666-6666 70 Simon Lecoq (444)444-4419 80 Dollard Tremblay (333)333-3333

Table Client2

noClient nomClient noTéléphone 10 Luc Sansom (999)999-9999 20 Dollard Tremblay (888)888-8888

30 Lin Bô (777)777-7777

40 Jean Leconte (666)666-6666 50 Hafedh Alaoui (555)555-5555 60 Marie Leconte (666)666-6666 70 Simon Lecoq (444)444-4419 80 Dollard Tremblay (333)333-3333

Client. noClient Client2.noClient

40 60

60 40

10 10

20 20

30 30

40 40

50 50

60 60

(24)

Renommer les colonnes

 Quels sont les Clients qui ont le même numéro de téléphone?

Client2(noClient2, nomClient2, noTéléphone) (Client)

noClient, noClient2 (Client   Client2(noClient2, nomClient2, noTéléphone) (Client))

Table Client

noClient nomClient noTéléphone 10 Luc Sansom (999)999-9999 20 Dollard Tremblay (888)888-8888

30 Lin Bô (777)777-7777

40 Jean Leconte (666)666-6666 50 Hafedh Alaoui (555)555-5555 60 Marie Leconte (666)666-6666 70 Simon Lecoq (444)444-4419 80 Dollard Tremblay (333)333-3333

Table Client2

noClient2 nomClient2 noTéléphone2 10 Luc Sansom (999)999-9999 20 Dollard Tremblay (888)888-8888

30 Lin Bô (777)777-7777

40 Jean Leconte (666)666-6666 50 Hafedh Alaoui (555)555-5555 60 Marie Leconte (666)666-6666 70 Simon Lecoq (444)444-4419 80 Dollard Tremblay (333)333-3333

noClient noClient2

40 60

60 40

10 10

20 20

(25)

5.3.7 Jointure-

Table Commande altérée

noCommande dateCommande numéroClient

1 01/ 06/ 2000 10

2 02/ 06/ 2000 20

3 02/ 06/ 2000 10

4 05/ 07/ 2000 10

5 09/ 07/ 2000 30

6 09/ 07/ 2000 20

7 15/ 07/ 2000 40

8 15/ 07/ 2000 40

noClient nomClient noTéléphone noCommande dateCommande numéroClient

10 Luc Sansom (999)999-9999 1 01/06/ 2000 10

10 Luc Sansom (999)999-9999 3 02/06/ 2000 10

10 Luc Sansom (999)999-9999 4 05/07/ 2000 10

20 Dollard Tremblay (888)888-8888 2 02/06/ 2000 20 20 Dollard Tremblay (888)888-8888 6 09/07/ 2000 20

30 Ye San Le Sou (777)777-7777 5 09/07/ 2000 30

40 Jean Leconte (666)666-6666 7 15/07/ 2000 40

40 Jean Leconte (666)666-6666 8 15/07/ 2000 40

Client  noClient = numéroClient Commande altérée =

noClient = numéroClient (Client  Commande altérée)

Table Client

noClient nomClient noTéléphone 10 Luc Sansom (999)999-9999 20 Dollard Tremblay (888)888-8888

30 Lin Bô (777)777-7777

40 Jean Leconte (666)666-6666 50 Hafedh Alaoui (555)555-5555 60 Marie Leconte (666)666-6666 70 Simon Lecoq (444)444-4419 80 Dollard Tremblay (333)333-3333

(26)

Cherchez les

LigneCommandes qui ont été livrées en une seule livraison

LigneCommande.noCommande,

LigneCommande.noArtilce, quantité, noLivraison, quantitéLivrée (LigneCommande 

LigneCommande.noCommande = DétailLivraison.noCommande ET

LigneCommande.noArticle = DétailLivraison.noArticle ET quantité = quantitéLivrée DétailLivraison)

Table LigneCommande noCommande noArticle quantité

1 10 10

1 70 5

1 90 1

2 40 2

2 95 3

3 20 1

4 40 1

4 50 1

5 70 3

5 10 5

5 20 5

6 10 5

6 40 1

7 50 1

7 95 2

8 20 3

Table DétailLivraison

noLivraison noCommande noArticle quantitéLivrée

100 1 10 7

100 1 70 5

101 1 10 3

102 2 40 2

102 2 95 1

100 3 20 1

103 1 90 1

104 4 40 1

105 5 70 2

noCommande noArticle quantité noLivraison quantitéLivrée

1 70 5 100 5

1 90 1 103 1

2 40 2 102 2

3 20 1 100 1

4 40 1 104 1

(27)

5.3.8 Jointure externe

 Inclure les « célibataires »

 La jointure externe à gauche

 T 1 = T 2 (célibataires de T 1 )

 La jointure externe à droite

 T 1 = T 2

 La jointure externe pleine

 T 1 == T 2

(28)

Produire les informations au sujet des Clients et de leurs Commandes incluant les informations sur les

Clients qui n’ont pas placé de

Commande

noCommande dateCommande noClientTable Commande

1 01/ 06/ 2000 10

2 02/ 06/ 2000 20

3 02/ 06/ 2000 10

4 05/ 07/ 2000 10

5 09/ 07/ 2000 30

6 09/ 07/ 2000 20

7 15/ 07/ 2000 40

8 15/ 07/ 2000 40

Client =

Commande

noClient nomClient noTéléphone noCommande dateCommande

10 Luc Sansom (999)999-9999 1 01/06/ 2000

10 Luc Sansom (999)999-9999 3 02/06/ 2000

10 Luc Sansom (999)999-9999 4 05/07/ 2000

20 Dollard Tremblay (888)888-8888 2 02/06/ 2000 20 Dollard Tremblay (888)888-8888 6 09/07/ 2000

30 Lin Bô (777)777-7777 5 09/07/ 2000

40 Jean Leconte (666)666-6666 7 15/07/ 2000

40 Jean Leconte (666)666-6666 8 15/07/ 2000

50 Hafedh Alaoui (555)555-5555 null null

60 Marie Leconte (666)666-6666 null null

70 Simon Lecoq (444)444-4419 null null

80 Dollard Tremblay (333)333-3333 null null Table Client

noClient nomClient noTéléphone 10 Luc Sansom (999)999-9999 20 Dollard Tremblay (888)888-8888

30 Lin Bô (777)777-7777

40 Jean Leconte (666)666-6666 50 Hafedh Alaoui (555)555-5555 60 Marie Leconte (666)666-6666 70 Simon Lecoq (444)444-4419 80 Dollard Tremblay (333)333-3333

(29)

5.3.9 Semi-jointure (  )

Table

Commande

noCommande dateCommande noClient

1 01/ 06/ 2000 10

2 02/ 06/ 2000 20

3 02/ 06/ 2000 10

4 05/ 07/ 2000 10

5 09/ 07/ 2000 30

6 09/ 07/ 2000 20

7 15/ 07/ 2000 40

8 15/ 07/ 2000 40

Client

Commande

noClient nomClient noTéléphone 10 Luc Sansom (999)999-9999 20 Dollard Tremblay (888)888-8888

30 Lin Bô (777)777-7777

40 Jean Leconte (666)666-6666

Table

Client

noClient nomClient noTéléphone

10 Luc Sansom (999)999-9999

20 Dollard Tremblay (888)888-8888

30 Lin Bô (777)777-7777

40 Jean Leconte (666)666-6666

50 Hafedh Alaoui (555)555-5555

60 Marie Leconte (666)666-6666

70 Simon Lecoq (444)444-4419

80 Dollard Tremblay (333)333-3333

(30)

5.3.10Opérations

ensemblistes (  ,  , -)

 Schémas compatibles

Table T 1

A B

1 1

2 2

Table T 2

A B

2 2

3 3

T 1T 2

A B

1 1

2 2

3 3

T 1T 2

A B

2 2

T 1 - T 2

A B

1 1

T 2 T 1

A B

3 3

(31)

Produire les noms et numéros de

téléphone des Employés qui sont aussi des Clients de la pépinière

( nomPersonne, noTéléphone ( Client (noClient, nomPersonne, noTéléphone)

(Client))) 

( nomPersonne, noTéléphone ( Employé (codeEmployé, nomPersonne, noTéléphone) (Employé)))

Table

Employé

codeEmployé nomEmployé noTéléphone CASD1 Dollard Tremblay (888)888-8888 PIOY1 Yan Piochuneshot 911

LAFH1 Yvan Lafleur (111)111-1111 HASC1 Jean Leconte (666)666-6666

nomPersonne noTéléphone Dollard Tremblay (888)888-8888 Jean Leconte (666)666-6666

équivalent à  si

compatibles

Table

Client

noClient nomClient noTéléphone

10 Luc Sansom (999)999-9999

20 Dollard Tremblay (888)888-8888

30 Lin Bô (777)777-7777

40 Jean Leconte (666)666-6666

50 Hafedh Alaoui (555)555-5555

60 Marie Leconte (666)666-6666

70 Simon Lecoq (444)444-4419

80 Dollard Tremblay (333)333-3333

(32)

5.3.11Division ()

A  B

– plus grande table C qui est telle que B  C  A

– ~ inverse du produit cartésien

T 1 (X)  T 2 (Y) =

–  X-Y (T 1 ) - (( X-Y (T 1 )  T 2 ) - T 1 )

(33)

Quelles sont les noCommande des

Commandes qui incluent tous les Articles dont le prixUnitaire est $10.99

noArticle 10

70

noArticle ( prixUnitaire = 10.99

(Article))

noCommande noArticle

1 10

1 70

1 90

2 40

2 95

3 20

4 40

4 50

5 70

5 10

5 20

6 10

6 40

7 50

7 95

noCommande, noArticle

(LigneCommande)

noCommande 1

5

noCommande, noArticle

(LigneCommande)  

noArticle ( prixUnitaire = 10.99

(Article))

(34)

5.3.12 Ensemble minimal d'opérations de l'algèbre relationnelle

 Sélection ()

 Projection ()

 Produit cartésien ()

 Union ()

 Différence (-)

 Renommage ()

(35)

5.3.13 Extensions de l'algèbre relationnelle pour les bases de données

 Fonctions sur colonnes

– opérations arithmétiques (+, - , *, /,…)

– manipulation de chaînes (concaténation, …)

– ...

 Fonctions de groupe (ou d'agrégat)

– e.g. total, moyenne, écart-type, min, max,…

 Récursivité

– e.g. fermeture transitive

Références

Documents relatifs

Pour définir une contrainte d'intégrité référentielle entre Commande et Client : sélectionnez la clé primaire noClient de la table Client et tirez-la sur la clé étrangère

titre nomProducteur nomActeur La vie est belle Elda Ferri Roberto Benigni La vie est belle Elda Ferri Nicoletta Braschi La vie est belle Elda Ferri Giorgio Cantarini La vie est

Schémas (LDD), modules codés et

 Exigence de performance : Le temps d'attente de la validation de l'identificateur de l'utilisateur et de la vérification des conditions requises pour un

Lors d'un prêt ou d'un retour , l' identificateur d'utilisateur et l' identificateur de l'exemplaire peuvent être saisis en utilisant un lecteur optique ou manuellement...

Menu Edit  Include Pour inclure dans le diagramme des artefacts qui sont déjà dans le référentiel Menu View  Zoom In/ Zoom Out Pour changer la taille à l'écran. Menu Utilities

2 Sélection d'une ligne par jointure dans une organisation par index groupant ou hachage hétérogène (CLUSTER). 3 Sélection d'une ligne par hachage sur clé candidate (PRIMARY

noSequence : INTEGER {Clé candidate : codeMatricule}. codeMatricule