Top Banner
XML to Relational Conversion using Theory of Regular Tree Grammar Murali Mani, Dongwon Lee VLDB Conference 2002 Vincent Berthier 23 octobre 2012 Vincent Berthier XML to Relational Conversion 23 octobre 2012 1 / 15
25

XML to Relational Conversion using Theory of Regular Tree Grammar

May 28, 2015

Download

Documents

TC1 : Données et Connaissances pour le web
Présentation de l'article "XML to Relational Conversion using Theory of Regular Tree Grammar" dans le cadre du contrôle continu pour le module.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: XML to Relational Conversion using Theory of Regular Tree Grammar

XML to Relational Conversionusing Theory of Regular Tree Grammar

Murali Mani, Dongwon LeeVLDB Conference 2002

Vincent Berthier

23 octobre 2012

Vincent Berthier XML to Relational Conversion 23 octobre 2012 1 / 15

Page 2: XML to Relational Conversion using Theory of Regular Tree Grammar

Sommaire

1 IntroductionMotivation & ContexteLe Problème

2 Travail réaliséDes grammaires régulièresAlgorithmeCréation des tablesQuelques plus

3 ConclusionDes problèmesQuestions

Vincent Berthier XML to Relational Conversion 23 octobre 2012 2 / 15

Page 3: XML to Relational Conversion using Theory of Regular Tree Grammar

Introduction Motivation & Contexte

Avec l’arrivée d’XPath et de XQuery en 1999, les bases de donnéesXML se développent.Une question légitime apparaît alors : peut-on passer d’une base XMLà une base relationnelle ?Certaines choses faites en XML ne peuvent pas forcément l’être enrelationnel...

Vincent Berthier XML to Relational Conversion 23 octobre 2012 3 / 15

Page 4: XML to Relational Conversion using Theory of Regular Tree Grammar

Introduction Le Problème

Les Unions XML dans du relationnel

En XML : Élèves → Étudiants | AuditeurLibreEn relationnel ?

Table : Élèves

id Étudiant ou AuditeurLibre1 21 256 7282 Patrick Dupont

Vincent Berthier XML to Relational Conversion 23 octobre 2012 4 / 15

Page 5: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Des grammaires régulières

Une grammaire de base

N = {Formation,Nom,Note,Eval ,Etudiant,Personne

AuditeurLibre,NumEtudiant,Prenom,Niveau,Coeff ,Email ,Tel}T = {formation, nom, note, eval , etudiant, personne

auditeurLibre, numEtudiant, prenom,Niveau,Coeff , email , tel}S = {Formation}P : Formation→ formation(Nom,Formation∗,AuditeurLibre∗)

Formation→ formation(Nom,Formation∗,Etudiant∗,Note|Eval)Etudiant → etudiant(NumEtudiant,Personne)

AuditeurLibre → auditeurLibre(Personne)

Personne → personne(Nom, (Email |Tel))Note → note(Niveau,Coeff )

Eval → eval(ε);Nom→ nom(ε)

Niveau → niveau(ε);Coeff → coeff (ε)

Email → email(ε);Tel → tel(ε)

Vincent Berthier XML to Relational Conversion 23 octobre 2012 5 / 15

Page 6: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Des grammaires régulières

Un exemple de graphe

formation

nom etudiant noteformation

niveau creditsauditeurLibrenom personne

nom emailnom tel

num

Vincent Berthier XML to Relational Conversion 23 octobre 2012 6 / 15

Page 7: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Des grammaires régulières

Normal Form 1 (NF1)

Respecte la première restriction{X → aX2;Y → aY2} ∈ P ⇒ X 6= Y

P : Formation→ formation((Nom,Formation∗,AuditeurLibre∗)|(Nom,Formation∗,Etudiant∗,Note|Eval))

Etudiant → etudiant(NumEtudiant,Personne)

AuditeurLibre → auditeurLibre(Personne)

Personne → personne(Nom, (Email |Tel))Note → note(Niveau,Coeff )

Eval → eval(ε);Nom→ nom(ε)

Niveau → niveau(ε);Credits → coeff (ε)

Email → email(ε);Tel → tel(ε)

Utilisée pour vérifier par exemple la validité d’un document par rapport àun schéma.

Vincent Berthier XML to Relational Conversion 23 octobre 2012 7 / 15

Page 8: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Des grammaires régulières

Normal Form 1 (NF1)

Respecte la première restriction{X → aX2;Y → aY2} ∈ P ⇒ X 6= Y

P : Formation→ formation((Nom,Formation∗,AuditeurLibre∗)|(Nom,Formation∗,Etudiant∗,Note|Eval))

Etudiant → etudiant(NumEtudiant,Personne)

AuditeurLibre → auditeurLibre(Personne)

Personne → personne(Nom, (Email |Tel))Note → note(Niveau,Coeff )

Eval → eval(ε);Nom→ nom(ε)

Niveau → niveau(ε);Credits → coeff (ε)

Email → email(ε);Tel → tel(ε)

Utilisée pour vérifier par exemple la validité d’un document par rapport àun schéma.

Vincent Berthier XML to Relational Conversion 23 octobre 2012 7 / 15

Page 9: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Des grammaires régulières

Normal Form 2 (NF2)

Enfreint la première restriction...mais fait disparaître les unions.

Avant

P : Formation→ formation((Nom,Formation∗,AuditeurLibre∗)|(Nom,Formation∗,Etudiant∗,Note|Eval))

Personne → personne(Nom, (Email |Tel))

Après

P : Formation→ formation(Nom,AuditeurLibre∗,Formation∗)Formation→ formation(Nom,Formation∗,Etudiant∗,Note)

Formation→ formation(Nom,Formation∗,Etudiant∗,Eval)

Personne → personne(Nom,Email)

Personne → personne(Nom,Tel)Vincent Berthier XML to Relational Conversion 23 octobre 2012 8 / 15

Page 10: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Algorithme

Inlining

Un principe simple : représenter un élément par l’ensemble des feuilles deson sous-graphe, en omettant les collections.

Exemple : Formation→ formation(Nom,Formation∗,Etudiant∗,Note)

Formation

Nom Formation Etudiant Note

Niveau Credits

Formation = {}

Vincent Berthier XML to Relational Conversion 23 octobre 2012 9 / 15

Page 11: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Algorithme

Inlining

Un principe simple : représenter un élément par l’ensemble des feuilles deson sous-graphe, en omettant les collections.

Exemple : Formation→ formation(Nom,Formation∗,Etudiant∗,Note)

Formation

Nom Formation Etudiant Note

Niveau Credits

Formation = {}

Vincent Berthier XML to Relational Conversion 23 octobre 2012 9 / 15

Page 12: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Algorithme

Inlining

Un principe simple : représenter un élément par l’ensemble des feuilles deson sous-graphe, en omettant les collections.

Exemple : Formation→ formation(Nom,Formation∗,Etudiant∗,Note)

Formation

Nom Formation Etudiant Note

Niveau Credits

Formation = {Nom}

Vincent Berthier XML to Relational Conversion 23 octobre 2012 9 / 15

Page 13: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Algorithme

Inlining

Un principe simple : représenter un élément par l’ensemble des feuilles deson sous-graphe, en omettant les collections.

Exemple : Formation→ formation(Nom,Formation∗,Etudiant∗,Note)

Formation

Nom Formation Etudiant Note

Niveau Credits

Formation = {Nom}

Vincent Berthier XML to Relational Conversion 23 octobre 2012 9 / 15

Page 14: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Algorithme

Inlining

Un principe simple : représenter un élément par l’ensemble des feuilles deson sous-graphe, en omettant les collections.

Exemple : Formation→ formation(Nom,Formation∗,Etudiant∗,Note)

Formation

Nom Formation Etudiant Note

Niveau Credits

Formation = {Nom}

Vincent Berthier XML to Relational Conversion 23 octobre 2012 9 / 15

Page 15: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Algorithme

Inlining

Un principe simple : représenter un élément par l’ensemble des feuilles deson sous-graphe, en omettant les collections.

Exemple : Formation→ formation(Nom,Formation∗,Etudiant∗,Note)

Formation

Nom Formation Etudiant Note

Niveau Credits

Formation = {Nom, Note.Niveau}

Vincent Berthier XML to Relational Conversion 23 octobre 2012 9 / 15

Page 16: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Algorithme

Inlining

Un principe simple : représenter un élément par l’ensemble des feuilles deson sous-graphe, en omettant les collections.

Exemple : Formation→ formation(Nom,Formation∗,Etudiant∗,Note)

Formation

Nom Formation Etudiant Note

Niveau Credits

Formation = {Nom, Note.Niveau, Note.Credits}

Vincent Berthier XML to Relational Conversion 23 octobre 2012 9 / 15

Page 17: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Création des tables

Résultat d’inlining

A partir des règles de la grammaire :

Formation→formation(Nom,Formation∗,AuditeurLibre∗)Formation→formation(Nom,Formation∗,Etudiant∗,Note)Formation→formation(Nom,Formation∗,Etudiant∗,Eval)Etudiant →etudiant(NumEtudiant,Personne)

AuditeurLibre →auditeurLibre(Personne)

Personne →personne(Nom,Email)

Personne →personne(Nom,Tel)

On obtient :

formation1(Nom)

formation2(Nom, Note.Niveau,Note.Credits)

formation3(Nom, Note.Eval)

etudiant1(NumEtudiant, Nom,Email)

etudiant2(NumEtudiant, Nom,Tel)

auditeurLibre1(Nom, Email)

auditeurLibre2(Nom, Tel)

Mais il manque...le mapping des collections...

Vincent Berthier XML to Relational Conversion 23 octobre 2012 10 / 15

Page 18: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Création des tables

Introduction des collections

Des formations d’un côté, des élèves de l’autre...

formation1(Nom) etudiant1(NumEtudiant, P.Nom, P.Email)formation2(Nom, N.Niveau, N.Credits)

×

etudiant2(NumEtudiant, P.Nom, P.Tel)formation3(Nom, Eval) auditeurLibre1(P.Nom, P.Email)

auditeurLibre2(P.Nom, P.Tel)

Une seule solution : un “produit cartésien”En respectant les règles de la grammaire bien sûr.

Vincent Berthier XML to Relational Conversion 23 octobre 2012 11 / 15

Page 19: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Création des tables

Introduction des collections

Des formations d’un côté, des élèves de l’autre...

formation1(Nom) etudiant1(NumEtudiant, P.Nom, P.Email)formation2(Nom, N.Niveau, N.Credits) × etudiant2(NumEtudiant, P.Nom, P.Tel)formation3(Nom, Eval) auditeurLibre1(P.Nom, P.Email)

auditeurLibre2(P.Nom, P.Tel)

Une seule solution : un “produit cartésien”En respectant les règles de la grammaire bien sûr.

Vincent Berthier XML to Relational Conversion 23 octobre 2012 11 / 15

Page 20: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Création des tables

Introduction des collections

Avec des clés étrangères

formation1auditeurLibre1formation1(nom, auditeurLibre1,formation1auditeurLibre1formation1)

formation1auditeurLibre1formation2(nom, auditeurLibre1,formation1auditeurLibre1formation2)

formation1auditeurLibre1formation3(nom, auditeurLibre1,formation1auditeurLibre1formation3)

formation1auditeurLibre2formation1(nom, auditeurLibre2,formation1auditeurLibre1formation1)

etc.

Vincent Berthier XML to Relational Conversion 23 octobre 2012 11 / 15

Page 21: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Création des tables

Un problème de taille

Qui dit produit cartésien, dit explosion du nombre de tables. On peutessayer de factoriser... mais au prix du “nullable”. Par exemple :

Table : Étudiant + AuditeurLibre → Élèves

Nom NumEtudiant P.Email P.Telnull null null

Table : Formation

Nom Formation N.Niveau N.Credits Eval Élèvesnull null null null null

Vincent Berthier XML to Relational Conversion 23 octobre 2012 12 / 15

Page 22: XML to Relational Conversion using Theory of Regular Tree Grammar

Travail réalisé Quelques plus

Ils ont aussi fait...

Les attributsIDREF, IDREFSLes récursionsContraintes sémantiques

Vincent Berthier XML to Relational Conversion 23 octobre 2012 13 / 15

Page 23: XML to Relational Conversion using Theory of Regular Tree Grammar

Conclusion Des problèmes

Quelques “problèmes”

Passage rapide sur la création des tablesDes règles précises sont données pour les contraintes sémantiquesMais tout est laissé à l’imagination du lecteur lorsqu’il s’agit de choisircomment organiser les tables...

Analyse légèreOn convertit une base de données en XMLOn reconvertit le fichier XML avec ce que nous proposonsOn vérifie qu’on retrouve bien ce qu’on avaitConclusion : ça marche !

Vincent Berthier XML to Relational Conversion 23 octobre 2012 14 / 15

Page 24: XML to Relational Conversion using Theory of Regular Tree Grammar

Conclusion Questions

A vous ?

Des questions ?

Vincent Berthier XML to Relational Conversion 23 octobre 2012 15 / 15

Page 25: XML to Relational Conversion using Theory of Regular Tree Grammar

Algorithme d’inlining

inline : currEl , currSet, attSet ⇒ ResultSetAssign the set of attributes in A(currEl) except IDREF and IDREFSattributes to attSet. Let the element type definition of currEl be givenby M(currEl) = (r1|r2|...|rn). Set ResultSet = φ

For each ri , we do the followingSet currSet = attSetLet the elements which occur in ri with occurence constraints [1, 1]after simplification be {e1, e2, ..., en}. For each ei do the following.

If M(ei ) ∈ τ̂ then currSet = currSet × ei

Else currSet = currSet × inline(ei , φ, φ)

If currSet = φ, currSet = currElResultSet = ResultSet ∪ currSet.

Return ResultSet

Vincent Berthier XML to Relational Conversion 23 octobre 2012 16 / 15