40
DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

  • View
    215

  • Download
    2

Embed Size (px)

Citation preview

Page 1: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

DTD Inference for Views of XML Data

Yannis Papakonstantinou and Victor VianuU.C. San Diego

Given by Irit Gefner

17.11.02

Page 2: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 2/40

על סדר היום

מוטיבציה

 וטענות הגדרות

אלגוריתם

סיכום

Page 3: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 3/40

מוטיבציה

Page 4: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 4/40

מוטיבציה

:נגדיר

מבנה נתונים המתאים למסמך XML.

מבנה נתונים המתאים ל DTD.

שאילתה על מסמך XML.

:המטרה

בתוצאת XML המתאים ביותר לחלקי ה DTDבניה של השאילתה.

Page 5: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 5/40

loto - Labeled Ordered Tree Object

Page 6: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 6/40

loto t over Σהגדרה -

.עץ סדור

כל קודקוד מתאים לאלמנט בXML.

( .תווית הקודקוד היא סוג האלמנטtype name)

Σ היא קבוצת ה type names ב XML.

נסמן בn)) את התווית של n עבור .n איבר ב t.

נסמן בtree(n) את תת העץ של t ששורשו הוא n.

Page 7: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 7/40

ltd - Loto Type Definition

root: dealer;dealer: UsedCars, NewCars;UsedCars: ad*;NewCars: ad*;ad: (model, year) + model;

Page 8: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 8/40

ltd d over Σהגדרה - ( מכיל הגדרה של סוג השורשtype name מ Σ .)

מתאים לכלa ב Σ שפה מעל Σ נסמן ב .d(a).

אםn1,n2,..,nk הם הבנים של n אז המילה ,(nk) (n1).. שייכת ל d((n))

נסמן בd(root).את הסוג של השורש

loto t את מספקd:אם

.d(root) הוא מסוג t- השורש של

..(nk) (n1) (n2) המילה n1,n2,..,nk עם הבנים t ב n- לכלd((n))שייכת ל

נסמן בT(d) את קבוצת ה lotos שמספקים את d.

Page 9: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 9/40

...הגדרות נוספותltd אם לכל רגולרי נקרא a ב Σ, d(a).שפה רגולרית

נאמר כיd,d’ אם שקוליםT(d)=T(d’).

נאמר כיd מ יותר הדוק d’ אם ,T(d) T(d’).

נאמר כיd לקבוצה הדוק T של lotos אם ,T=T(d).

נאמר כיd ל קרובT אם T(d) T.

Page 10: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 10/40

לכל a ב

Σ, נסמן ב

L

a

את

השפה

שמכילה

את כל

המילי

ם (n

k

)

(n

1

)..

עבור כל

n

1

,..,

n

k

שהם בני

ם

של

איבר ב t בעל

תוי

ת

Lad = {(model,year),(model)}

סגירות תחת החלפת תת עץ קבוצהT של lotos כאשר:סגורה תחת החלפת תת עץ

’’t. אז (n’)=(n). ומתקיים ’t איבר ב ’t. n איבר ב T. n ב ’t,tאם .T שייך ל tree(n’) ב tree(n) על ידי החלפת tהמתקבל מ

...הגדרות נוספות לכלa ב Σ נסמן ב ,La את השפה שמכילה את כל המילים (nk)

(n1).. עבור כל n1,..,nk שהם בנים של איבר בt בעל תווית a.

Page 11: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 11/40

מספר טענות

לקבוצהT של lotos יש ltd אם"ם מתקיימים שני הדוק סגורה תחת החלפת תת עץ.T שפה רגולרית. Laהתנאים:

. אם יש כאלה נחפש את קירובים נתעניין בהדוק ltd אין Tאם ל מביניהם.הדוק ביותר ה

לקבוצהT מעל Σ יש ltd אם"ם לכל הדוק ביותר a ב Σ, La היא שפה רגולרית.

Page 12: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 12/40

- המשך -

אם איןltd קירובים, יש אינסוף הדוק ביותר.

root: section;section: intro, section*, conc;

.conc וה intro נדון בתוצאת השאילתה המבקשת את כל ה

root: view;view: ( + intro), (intro + conc)*, conc;

Ltd:קרוב יותר

root: view;view: (intro + conc)*;

Ltd:קרוב

Page 13: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 13/40

DTDמוגבל ראינו מסמך בודד שלא ניתן למצוא לוltd.הדוק

.בעייתיות בשרשור מסמכים

.אי יכולת לבטא מספר חזרות של סוג מסוים

.specializationנגדיר מנגנון root: UsedCars;UsedCars: ad*;ad: model, year;

root: NewCars;NewCars: ad*;ad: model;

root: dealers;dealers: dealer*;dealer: UsedCars, NewCars;UsedCars: ad*;NewCars: ad*;ad: (model,year) + model;

ראינו מסמך בודד שלא ניתן למצוא לוltd.הדוק

.בעייתיות בשרשור מסמכים

ראינו מסמך בודד שלא ניתן למצוא לוltd.הדוק

Page 14: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 14/40

Specializaion

Specialized ltd d = < Σ , Σ’ , d , >

d הוא ltd מעל Σ.

d הוא specialized ltd מעל Σ’.

ממפה מ Σ’ ל Σ לכל תווית ב .Σ יש קבוצה של תוויות ב ,Σ’

כאלו אפשר להמיר לאוטומטים מעל עצים. ולכן בדיקת הכלה ltdsהערה: למשל תבוצע בזמן אקספוננציאלי ובדיקת ריקנות בזמן פולינומיאלי.

root: dealer;dealer: UsedCars, NewCars;UsedCars: ad_u*;NewCars: ad_n*;ad_u: model,year;ad_n: model;

root: dealer;dealer: (UsedCars, NewCars;UsedCars: ad*;NewCars: ad*;ad: (model, year) + model;

Page 15: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 15/40

Select loto-qlSelect X where body

:לכל קודקוד פנימי, תווית מהצורה p1.X1… pkXkpk+1

< :לכל צלע היוצאת מקודקוד, תווית מהצורה Xi,p >

Xi .משתנה שמופיע בקודקוד p.ביטוי רגולרי

p1.X1… pkXkpk+1

pl.X’.pr

root

<p’>

<X’,p> פונקצית הקשירה :

(X’) = n0 כך ש n0…nm יש במסמך איברים

(n1)… (nm)p ול nm יש בנים y11..y1i1…y(k+1)1..y(k+1)i(k+1)

j k 0כך שלכל

(yj1)… (yjik)pj (Xj) = yjijמתקיים

Page 16: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 16/40

דוגמא

root: journal;journal: (mathArticle, compAtricle)*;mathArticle: abstract, theorem*, summary,

ref;compArticle: abstract, section+, summary, ref;theorem: (proof + theorem)*;Section: intro, section*, conc;

Page 17: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 17/40

Select loto-ql

journal

Σ*(intro+conc).X. Σ*

<CompArticle, section+>

שאילתה לקבלת כל רכיבי הintro וה conc המופיעים בעומק .CompArticleכלשהו תחת

root: view;view: (intro, A, conc)*;A: (intro, A, conc)*;

Page 18: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 18/40

Select loto-ql

journal

Σ*mathArticle.X. Σ*

<>

שאילתה לקבלת כל רכיבי הmathArticle שיש תחתם רכיב theorem שתחתיו יש proof.

<X, theorem>

Σ* proof Σ*

Page 19: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 19/40

רגע לפני האלגוריתם

ראינו כי בניה שלltd לתוצאה של שאילתה זקוקה לעיתים .specializationלמנגנון ה

וכן כי יש שאילתות שהתוצאה שלהן תתואר ע"יltd חסר הקשר.

בהינתןltd d ושאילתה q loto-ql השאלה האם יש ltd רגולרי , אינה ניתנת להכרעה.q(T(d))הדוק או הדוק ביותר עבור

זאת משום שכפי שראינו הרגולריות היא תנאי הכרחי לקיוםltd הדוק. והבעיה, האם דקדוק חסר הקשר מגדיר שפה רגולרית

אינה כריעה.

Page 20: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 20/40

ניווט לעומק

נניחltd d וביטוי רגולרי p מעל Σ. a תווית ב Σ.

, יש מסלול שיוצא d שמספקים את lotosנדון בשאלה אם ב . p ונמצא ב aמאיבר בעל תווית

נאמר כי:

-p ב מסופק a אם יש מסלול כזה בחלק מ .T(d).

-p ב לא מסופק a.אם אין אף מסלול כזה .

-p ב ואלידי a אם יש מסלול כזה לכל איבר בעל תווית .a בכל loto ב T(d).

Page 21: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 21/40

רדוקציה לאוטומטים מעל עצים

נסמן בRd את קבוצת ה lotos ששורשם a ומספקים את d .

נסמן בRp את קבוצת ה lotos ששורשם ב a וממנו יוצא מסלול .pב

מהם ניתן לבנות בזמן פולינומיאלי אוטומטי עציםtop-down R’d, R’pלא דטרמיניסטים.

p ב מסופק a אם ,R’d ∩ R’p .לא ריק. בדיקה פולינומיאלית

p ב ואלידי a אם ,R’d R’p.בדיקה אקספוננציאלית .

Page 22: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 22/40

Type Tightening

נגדיר לקבוצהT(d) של lotos תת-קבוצה מקסימלית של ,lotos .a ואלידי ב pשבה

( זוהי תת-קבוצה ממש, אם בd)T, p.מסופק אך לא ואלידי

נבנהspecialized ltd :עבור קבוצה זו. ונסמן tighten(a,d,p)

הבניה אפשרית:

הפעלתspecialization על Rd ∩ Rp

Page 23: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 23/40

1אלגוריתם –

יהיוltd d והשאילתה q מעל Σ נבנה את .dq

– השורשview.

לכלa ב Σ, dq(a) = d(a)

יהאp אוטומט מעל Σ שמקבל את p עם .. ופונקצית המעברים sמצב ההתחלה

תהאph השפה המתקבלת מ p אם מתחילים .hממצב

pl.X.pr

root

<p>

Page 24: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 24/40

1אלגוריתם –

נגדיר אתdq(view):כדקדוק חסר הקשר

הטרמינלים הםΣ.

המשתנים הם זוגות<h,a>

p מצב ב hכאשר

<s,view>המשתנה ההתחלתי הוא

נגדיר את הייצור ב<h,a>

אינו מצב מקבל באוטומט לבין המקרה hנבחין בין המקרה בו שהוא כן.

Page 25: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 25/40

אםh.אינו מצב מקבל, הניווט לעומק

לכל סוגb ב ,Σ. (h,b) h= ’

ph’ ואלידי ב b {<h’,b>}

ph’ מסופק אך לא ואלידי בb {,<h’,b>} <h,a>

ph’ לא מסופק בb {}

1אלגוריתם –

Page 26: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 26/40

1אלגוריתם – אםh בבנים של( מצב מקבל, הניווט לרוחב a)

<h,a> th(d(a))

th עושה התאמה של כל מילה w ב d(a) לתווית pl.X.pr

ההתאמה:

מעבר על אותיותw .

לכל אותz בדיקה אם תחילית המילה עד לאותה ,.pr ושאר המילה ב plאות נמצאת ב

אם יש התאמה פולטת לרצףz<h,z>

אם אין התאמה פולטת לרצף<h,z>

pl.X.pr

root

<p>

Page 27: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 27/40

1דוגמא - שאילתה

journal

Σ*(intro+conc).X. Σ*

<CompArticle, section+>

שאילתה לקבלת כל רכיבי הintro וה conc המופיעים בעומק .CompArticleכלשהו תחת

Page 28: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 28/40

1אלגוריתם – דוגמא

אוטומט שמקבל את(compArticle,section+):

(s,compArticle) = h1 Ph1 = section+

Ph1 ואלידי ב compArticleולכן

<s,compArticle> {<h1,compArticle>}

(h1,section) = h2 Ph2 = section*

Ph2 ואלידי ב sectionולכן

<h1,compArticle> {<h2,section>}

Page 29: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 29/40

1אלגוריתם –דוגמא

h2 הוא מצב מקבל. צריך להפעיל את f:

*Σ*(intro+conc).X. Σ ובין התווית d(section)התאמה בין

d(section) = intro, section*, conc

w = intro, conc>==

intro, <h2,intro>, conc, <h2,conc>

w = intro, section, conc >==

intro, <h2,intro>, <h2, section>, conc, <h2,conc>

w ==> intro, <h2,intro>, <h2, section>*, conc, <h2,conc>

Page 30: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 30/40

- תוצאה1דוגמא

<s,compArticle> {<h1,compArticle>} <h1,compArticle> {<h2,section>}

<h2,section> intro, <h2,intro>, <h2, section>*, conc, <h2,conc>

<h2,intro> = <h2,conc> =

:ביטול מצבים מיותריםroot: view;view: (intro, A*, conc)*;A: (intro, A*, conc)*;

Page 31: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 31/40

2אלגוריתם –

צריך להבטיח את קיום המסלולp’ מ X.

השפהd(view)תשתמש ב

d’ = specialized ltds tighten(a,d,p’)

pl.X.pr

root

<p>

*

<X,p’>

Page 32: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 32/40

, האיבר המתאים ב ’a, אם מתקיים התנאי נמשיך עם Σ ב aלכל d’:כלומר .

p’ ואלידי ב a {<h’,a’>}

p’ מסופק אך לא ואלידי בa {,<h’,a’>} <h,a>

p’ לא מסופק בa {}

2אלגוריתם –

Page 33: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 33/40

2דוגמא - שאילתה

journal

Σ*mathArticle.X. Σ*

<>

שאילתה לקבלת כל רכיבי הmathArticle שיש תחתם רכיב theorem שתחתיו יש proof.

<X, theorem>

Σ* proof Σ*

Page 34: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 34/40

2אלגוריתם – דוגמא

שיש mathArticles על מנת להבדיל בין specializationיש לבצע אחרים.mathArticles ובין proof עם theroemתחתם

Specialized ltd:

root: journal;Journal: (mathArticle + compArticle +

p_mathArticle)*;p_mathArticle:

abstract, theorem*, p_theorem, theorem*, summary, ref;p_theorem: (proof + theorem)*, proof, (proof +

theorem)*; * Σ*p_mathArticle.X. Σ ובין d(journal) תתאים בין fואז

Page 35: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 35/40

- תוצאה2דוגמא

root: view;view: p_mathArticle*;p_mathArticle:

abstract, theorem*, p_theorem, theorem*, summary, ref;p_theorem: (proof + theorem)*, proof, (proof +

theorem)*;theorem: (proof + theorem)*;

Page 36: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 36/40

תוצאה

בהנתןltd d רגולרי ושאילתת loto-ql q ניתן לבנות .specialized ltd עבור חסר הקשר הדוק ,q(T(d)).

סיבוכיות הבניה: אקספוננציאלית.

.q ואקספוננציאלי ב dהגודל: פולינומיאלי ב

אם בltd אין מעגלים או שבשאילתה אין מעגלים לעומק, ניתן .q(T(d)), עבור רגולרי הדוק specialized ltdלבנות

Page 37: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 37/40

שאילתות מורכבותהרחבה:

.ניתן להכליל להרבה משתנים

שאילתות הכוללות attributes.וטקסט

למשל( שאילתה עם בניה מורכבת של התוצאה group by)

ביצוע:

צריך לקחת בחשבון משתנים ב pl וב pr.כלומר אחים ,

צריך לבצע tighten.לכל משתנה

.בניווט לעומק צריך לקשר בין אוטומטים

Page 38: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 38/40

שימושים

בהינתןltd d,d’ רגולריים ושאילתה loto-ql q ניתן לקבוע אם ,q(T(d))T(d’).

ההוכחה תשתמש ב:

בדיקת הכלה בין דקדוק חסר הקשר לשפה רגולרית-

בדיקת הכלה בין שפות עצים רגולריים-

סיבוכיות: אקספוננציאלית

Page 39: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

Type Inference 39/40

שימושים

:בדיקת התאמה

ניתן לבדוק אם מבניות תוצאה של שאילתה מתאימה להגדרה קודמת.

אופטימיזציות

- באחסון התוצאה

- בניית שאילות וביצוען

( הצגת התוצאהXSL)

Page 40: DTD Inference for Views of XML Data Yannis Papakonstantinou and Victor Vianu U.C. San Diego Given by Irit Gefner 17.11.02

THE END!THE END!