1 / 12

Cours 4 : Langage SQL & Algèbre relationnelle

Cours 4 : Langage SQL & Algèbre relationnelle. Nguyen TuanLoc. Rappel sur l’algèbre relationnel. Normalisation Forme conjonctive (p11 ν p12 v … v p1n) Λ (pm1 ν pm2 v … v pmn) Forme disjonctive (p11 Λ p12 Λ … Λ p1n) v (pm1 Λ pm2 Λ … Λ pmn) (souvent disjonctive).

waseemah
Download Presentation

Cours 4 : Langage SQL & Algèbre relationnelle

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Cours 4 : Langage SQL & Algèbre relationnelle Nguyen TuanLoc

  2. Rappel sur l’algèbre relationnel • Normalisation • Forme conjonctive (p11 ν p12 v…v p1n) Λ (pm1 ν pm2 v…v pmn) • Forme disjonctive (p11 Λ p12Λ…Λp1n) v (pm1 Λ pm2Λ…Λ pmn) (souvent disjonctive)

  3. Exemple: schéma de la base de données pour les étudiants de la MIAGE Paris 12

  4. Conjonctive SELECT ENSEIGNANTS.nom, ENSEIGNANTS.prenom, MATIERES.nommat FROM MATIERES INNER JOIN (ENSEIGNANTS INNER JOIN ENSEIGN_MAT ON ENSEIGNANTS.codens = ENSEIGN_MAT.codens) ON MATIERES.codemat = ENSEIGN_MAT.codemat WHERE (((ENSEIGNANTS.nom)="NGUYEN") AND ((MATIERES.nommat)="ACCESS" Or (MATIERES.nommat)="BASE DE DONNEES"));

  5. Disjonctive SELECT ENSEIGNANTS.nom, ENSEIGNANTS.prenom, MATIERES.nommat FROM MATIERES INNER JOIN (ENSEIGNANTS INNER JOIN ENSEIGN_MAT ON ENSEIGNANTS.codens = ENSEIGN_MAT.codens) ON MATIERES.codemat = ENSEIGN_MAT.codemat WHERE ( ( (ENSEIGNANTS.nom)="NGUYEN" AND (MATIERES.nommat)="BASE DE DONNEES") OR ( (MATIERES.nommat)="ACCESS" AND (MATIERES.nommat)="BASE DE DONNEES"));

  6. Normalisation de requête • p1 Λ p2 < => p2 Λ p1 • p1 v p2 < => p2 v p1 (commutativité) • p1Λ(p2 Λ p3) < => p1Λp2Λp3 • p1v(p2 v p3) < => p1vp2vp3 (associativité) • p1Λ(p2vp3) < =>(p1Λp2)v(p1Λp3) • p1v(p2Λp3) < =>(p1vp2) Λ(p1vp3) • !(p1 Λ p2) < =>!p1 v !p2 • !!(p) < => p

  7. Exercice SELECT Title FROM Emp WHERE (Not (Title=’’linux’’) AND (Title=’’linux’’ OR Title=’’windows’’) AND Not (Title = ’’unix’’)) OR Ename = ’’Toward Linus’’; On suppose: p1 = Title=’’linux’’ p2 = Title=’’windows’’ p3 = Ename = ’’Toward Linus’’

  8. Forme normale (!p1 Λ (p1 v p2) Λ !p2) v p3 • Disjonctive: [(!p1 Λ p1) v (!p1 Λp2)] Λ !p2) v p3< => (!p2 Λ [(!p1 Λ p1) v (!p1 Λp2)]) v p3< => (!p2Λ(!p1 Λ p1))v(!p2Λ(!p1Λp2)) v p3 < =>(!p2Λ!p1Λp1)v(!p2Λ!p1Λp2) v p3 < =>(!p2 Λfalse) v (!p1 Λ false) v p3 < => false v false v p3 < => p3

  9. Requête finale SELECT Title From Emp WHERE Ename =’’Toward Linus’’;

  10. Règle de transformation • Commutativité: R x S Ξ S x R R |x| S Ξ S |x| R R U S Ξ S U R • Associativité ( R x S ) x T = R x ( S x T) ( R |x| S ) |x| T = R |x| ( S |x| T) • Idempotence ΠA’ (ΠA’’(R) ) = ΠA’(R) (avec A’’ dans A’) …

  11. Analyse • Mise de la requête en forme normale • Analyse lexical et syntaxique • Type incorrect ou inexistant (schéma de la relation)

  12. Simplification • p Λ p < => p • p v p < => p • p Λ true < =>p • p v false < => p • p Λ false < => false • p v true < => true • p Λ !p < => false • p v !p < => true • p1 Λ (p1 v p2) < => p1 • P1 v (p1 Λ p2) < => p1

More Related