1 / 41

Informationsintegration Containment und Local-as-View Anfragebearbeitung

Informationsintegration Containment und Local-as-View Anfragebearbeitung. 12.1.2006 Felix Naumann. Überblick. Wiederholung Global-as-View (GaV) & GaV Anfragebearbeitung Local-as-View (LaV) LaV Anfragebearbeitung Containment Definition Test Nutzbarkeit und Nützlichkeit von Views.

Download Presentation

Informationsintegration Containment und Local-as-View Anfragebearbeitung

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. InformationsintegrationContainment und Local-as-View Anfragebearbeitung 12.1.2006 Felix Naumann

  2. Überblick • Wiederholung • Global-as-View (GaV) & GaV Anfragebearbeitung • Local-as-View (LaV) • LaV Anfragebearbeitung • Containment • Definition • Test • Nutzbarkeit und Nützlichkeit von Views Felix Naumann, VL Informationsintegration, WS 05/06

  3. Global as View / Local as View • Global as View • Relationen des globalen Schemas werden als Sichten auf die lokalen Schemas der Quellen ausgedrückt • Local as View • Relationen der Schemas der Quellen werden als Sichten auf das globale Schema ausgedrückt. Felix Naumann, VL Informationsintegration, WS 05/06

  4. Global as View (GaV) – Beispiel S1: IMDB(Titel, Regie, Jahr, Genre) S2: MyMovies(Titel, Regie, Jahr, Genre) S3: RegieDB(Titel, Regie) S4: GenreDB(Titel, Jahr, Genre) Globales Schema Film(Titel, Regie, Jahr, Genre) CREATE VIEW Film AS SELECT * FROM IMDB UNION SELECT * FROM MyMovies UNION SELECT RegieDB.Titel, RegieDB.Regie, GenreDB.Jahr, GenreDB.Genre FROM RegieDB, GenreDB WHERE RegieDB.Titel = GenreDB.Titel Quelle: VL „Data Integration“, Alon Halevy, University of Washington, 2002 Felix Naumann, VL Informationsintegration, WS 05/06

  5. Anfragebearbeitung – GaV • Gegeben: • Anfrage an globales Schema • Insbesondere: Auf Relationen des globalen Schemas • Für jede globale Relation genau eine Sicht auf lokale Quellen • Gesucht: • Alle Tupel, die die Anfragebedingungen erfüllen • Aber: Daten sind in lokalen Quellen gespeichert. • Idee: • Ersetze jede Relation der Anfrage durch ihre Sicht (View Expansion, Query Unfolding). • Geschachtelte Anfrage Felix Naumann, VL Informationsintegration, WS 05/06

  6. SELECT Titel, Jahr FROM ( SELECT * FROM IMDB UNION SELECT R.Titel, R.Regie, G.Jahr, G.Genre FROM RegieDB R, GenreDB G WHERE R.Titel = G.Titel ) WHERE Jahr = ‚2003‘ GaV – Beispiel Globales Schema Film(Titel, Regie, Jahr, Genre) Programm(Kino, Titel, Zeit) S1: IMDB(Titel, Regie, Jahr, Genre) S2: RegieDB(Titel, Regie) S3: GenreDB(Titel, Jahr, Genre) SELECT Titel, Jahr FROM Film WHERE Jahr = ‚2003‘ Felix Naumann, VL Informationsintegration, WS 05/06

  7. SELECT F.Titel, F.Jahr FROM ( SELECT * FROM IMDB UNION SELECT R.Titel, R.Regie, G.Jahr, G.Genre FROM RegieDB R, GenreDB G WHERE R.Titel = G.Titel ) AS F, ( SELECT * FROM KinoDB ) AS P WHERE F.Titel = P.Titel AND P.Zeit > 20:00 GaV – Beispiel S1: IMDB(Titel, Regie, Jahr, Genre) S2: RegieDB(Titel, Regie) S3: GenreDB(Titel, Jahr, Genre) S7: KinoDB(Kino, Genre, Zeit) SELECT F.Titel, P.Kino FROM Film F, Programm P WHERE F.Titel = P.Titel AND P.Zeit > 20:00 Felix Naumann, VL Informationsintegration, WS 05/06

  8. Global as View (GaV) • Anfrageumschreibung entspricht Sichtentfaltung • Ersetze Sicht durch Sicht-Definition. • Konzeptionell: Ausführung der Anfragen von innen nach außen und Speicherung in temporären Relationen. • Tatsächlich: Optimierungspotential durch Umschreiben der Anfrage (Entschachtelung) • Konzeptionell simpel • Neue Quellen hinzufügen ist schwierig. • Alle bisherigen Quellen müssen betrachtet werden. • Geeignet für materialisierte Integration Felix Naumann, VL Informationsintegration, WS 05/06

  9. Überblick • Wiederholung • Global-as-View (GaV) & GaV Anfragebearbeitung • Local-as-View (LaV) • LaV Anfragebearbeitung • Containment • Definition • Test • Nutzbarkeit und Nützlichkeit von Views Felix Naumann, VL Informationsintegration, WS 05/06

  10. Local as View (LaV) – Beispiel Globales Schema Film(Titel, Regie, Jahr, Genre) CREATE VIEW S1 AS SELECT * FROM Film CREATE VIEW S2 AS SELECT * FROM Film CREATE VIEW S3 AS SELECT Film.Titel, Film.Regie FROM Film CREATE VIEW S4 AS SELECT Film.Titel, Film.Jahr, Film.Genre FROM Film S1: IMDB(Titel, Regie, Jahr, Genre) S2: MyMovies(Titel, Regie, Jahr, Genre) S3: RegieDB(Titel, Regie) S4: GenreDB(Titel, Jahr, Genre) Quelle: VL „Data Integration“, Alon Halevy, University of Washington, 2002 Felix Naumann, VL Informationsintegration, WS 05/06

  11. Local as View (LaV) – Beispiel Globales Schema Film(Titel, Regie, Jahr, Genre) CREATE VIEW S9 AS SELECT Titel, NULL, Jahr FROM Film S9: ActorDB(Titel, Schauspieler, Jahr) Felix Naumann, VL Informationsintegration, WS 05/06

  12. Local as View (LaV) – Beispiel Globales Schema Film(Titel, Regie, Jahr, Genre) Programm(Kino, Titel, Zeit) CREATE VIEW S7 AS SELECT Programm.Kino, Film.Genre FROM Film, Programm WHERE Film.Titel = Programm.Titel S7: KinoDB(Kino, Genre) Assoziationen des globalen Schemas können in der Sicht hergestellt werden. Felix Naumann, VL Informationsintegration, WS 05/06

  13. Local as View (LaV) – Beispiel Globales Schema Film(Titel, Regie, Jahr, Genre) Programm(Kino, Titel, Zeit) CREATE VIEW S8 AS SELECT Titel, Regie, NULL, Genre FROM Film WHERE Jahr > 2000 S8: NeueFilme(Titel, Regie, Genre) (Nebenbedingung: Jahr > 2000) Felix Naumann, VL Informationsintegration, WS 05/06

  14. Local as View (LaV) – Beispiel CREATE VIEW S1 AS SELECT * FROM NeuerFilm CREATE VIEW S2 AS SELECT * FROM NeuerFilm Globales Schema NeuerFilm(Titel, Regie, Jahr, Genre) Programm(Kino, Titel, Zeit) Nebenbedingung: Jahr > 2000 S1: IMDB(Titel, Regie, Jahr, Genre) S2: MyMovies(Titel, Regie, Jahr, Genre) Felix Naumann, VL Informationsintegration, WS 05/06

  15. Local as View (LaV) • Flexibel • Beschreibung der Quellen mit voller Mächtigkeit der Anfragesprache • Quellen können leicht hinzugefügt werden (unabhängig von bisherigen Quellen) • Anfrageumschreibung schwierig • Answering Queries using Views • Viele potentielle (und überlappende) Pläne • Geeignet für virtuelle Integration Felix Naumann, VL Informationsintegration, WS 05/06

  16. Überblick • Wiederholung • Global-as-View (GaV) & GaV Anfragebearbeitung • Local-as-View (LaV) • LaV Anfragebearbeitung • Containment • Definition • Test • Nutzbarkeit und Nützlichkeit von Views Felix Naumann, VL Informationsintegration, WS 05/06

  17. Problem Anfrageverarbeitung Globales Schema Film(Titel, Regie, Jahr, Genre) LaV CREATE VIEW S1 AS SELECT * FROM Film CREATE VIEW S2 AS SELECT Film.Titel, Film.Regie FROM Film CREATE VIEW S3 AS SELECT Film.Titel, Film.Jahr, Film.Genre FROM Film S1: IMDB(Titel, Regie, Jahr, Genre) S2: RegieDB(Titel, Regie) S3: GenreDB(Titel, Jahr, Genre) GaV CREATE VIEW Film AS SELECT * FROM IMDB UNION SELECT R.Titel, R.Regie, G.Jahr, G.Genre FROM RegieDB R, GenreDB G WHERE R.Titel = G.Titel Felix Naumann, VL Informationsintegration, WS 05/06

  18. Anfragebearbeitung – LaV • Gegeben: • Anfrage an globales Schema • Insbesondere: Auf Relationen des globalen Schemas • Für jede lokale Relation genau eine Sicht auf globales Schema • Gesucht: • Alle Tupel, die die Anfragebedingungen erfüllen • Aber: Daten sind in lokalen Quellen gespeichert. • Idee: • Anfrageumschreibung durch Einbeziehung der Sichten • Kombiniere geschickt die einzelnen Sichten zu einer Anfrage, so dass deren Ergebnis einen Teil der Anfrage (oder die ganze Anfrage) beantworten. Felix Naumann, VL Informationsintegration, WS 05/06

  19. Umgeschriebene Anfrage SELECT prof FROM DB-kurs D WHERE D.univ = „Humboldt“ LaV Anfrageumschreibung – Beispiel Ausschnitt Globales Schema Lehrt(prof,kurs_id, sem, eval, univ) Kurs(kurs_id, titel, univ) Quelle 1: Alle Datenbankveranstalt. CREATE VIEW DB-kurs AS SELECT K.titel, L.prof, K.kurs_id, K.univ FROM Lehrt L, Kurs K WHERE L.kurs_id = K.kurs_id AND L.univ = K.univ AND K.titel LIKE „%_Datenbanken“ Quelle 2: Alle Humboldtvorlesungen CREATE VIEW Hum-VL AS SELECT K.titel, L.prof, K.kurs_id, K.univ FROM Lehrt L, Kurs K WHERE L.kurs_id = K.kurs_id AND K.univ = „Humboldt“ AND L.univ = „Humboldt“ AND K.titel LIKE „%VL_%“ Globale Anfrage SELECT prof FROM Lehrt L, Kurs K WHERE L.kurs_id = K.kurs_id AND K.titel LIKE „%_Datenbanken“ AND L.univ = „Humboldt“ Frage: Warum nicht Quelle 2 einbeziehen? Felix Naumann, VL Informationsintegration, WS 05/06

  20. LaV Visualisierung (OWA) Nutzer-Anfrage SELECT ??? FROM RelB WHERE ??? Globales Schema RelA RelB Anfrage- umschreibung LaV RelC = RelA ⋈ RelB Umgeschriebene Anfrage SELECT ??? FROM RelD WHERE ??? UNION SELECT Attr(B) FROM RelC WHERE ??? RelD = RelB Lokales Schema Lokales Schema RelC RelD Felix Naumann, VL Informationsintegration, WS 05/06

  21. LaV Visualisierung Nutzer-Anfrage SELECT ??? FROM RelA, RelB WHERE ??? Globales Schema RelA RelB LaV Anfrage- umschreibung RelC = RelA ⋈ RelB RelB = RelD Umgeschriebene Anfrage SELECT ??? FROM RelC WHERE ??? Lokales Schema Lokales Schema RelC RelD Felix Naumann, VL Informationsintegration, WS 05/06

  22. Umgeschriebene Anfrage SELECT titel, kurs_id FROM DB-kurs D WHERE D.univ = „Humboldt“ UNION SELECT titel, kurs_id FROM Hum-VL LaV – Beispiel Ausschnitt Globales Schema Lehrt(prof,kurs_id, sem, eval, univ) Kurs(kurs_id, titel, univ) Quelle 2: Alle Humboldtvorlesungen CREATE VIEW Hum-VL AS SELECT K.titel, L.prof, K.kurs_id, K.univ FROM Lehrt L, Kurs K WHERE L.kurs_id = K.kurs_id AND K.univ = „Humboldt“ AND L.univ = „Humboldt“ AND K.titel LIKE „%VL_%“ Quelle 1: Alle Datenbankveranstalt. CREATE VIEW DB-kurs AS SELECT K.titel, L.prof, K.kurs_id, K.univ FROM Lehrt L, Kurs K WHERE L.kurs_id = K.kurs_id AND L.univ = K.univ AND K.titel LIKE „%_Datenbanken“ Globale Anfrage SELECT titel, kurs_id FROM Kurs K WHERE L.univ = „Humboldt“ Frage: Warum hier doch Quelle 2 einbeziehen? Felix Naumann, VL Informationsintegration, WS 05/06

  23. Vollständige Antwort (CWA) Maximale Antwort LaV – Beispiel Vergleich Globale Anfrage SELECT prof FROM Lehrt L, Kurs K WHERE L.kurs_id = K.kurs_id AND K.titel = „%_Datenbanken“ AND L.univ = „Humboldt“ Umgeschriebene Anfrage SELECT prof FROM DB-kurs D WHERE D.univ = „Humboldt“ Globale Anfrage SELECT titel, kurs_id FROM Kurs K WHERE L.univ = „Humboldt“ Umgeschriebene Anfrage SELECT titel, kurs_id FROM DB-kurs D WHERE D.univ = „Humboldt“ UNION SELECT titel, kurs_id FROM Hum-VL Frage: Welche Daten fehlen hier? Felix Naumann, VL Informationsintegration, WS 05/06

  24. LaV – Anfragebearbeitung • Gegeben: Anfrage Q und Sichten V1, ..., Vn • Gesucht: Umgeschriebene Anfrage Q‘, die • bei Optimierung (mit MVs): äquivalent ist (Q = Q‘). • bei Integration: maximal enthalten ist. • D.h. Q  Q‘ und • es existiert kein Q‘‘ mit Q  Q‘‘  Q‘ wobei Q‘‘  Q‘. • Problem: • Wie definiert und testet man Äquivalenz bzw. maximal containment? Felix Naumann, VL Informationsintegration, WS 05/06

  25. Überblick • Wiederholung • Global-as-View (GaV) & GaV Anfragebearbeitung • Local-as-View (LaV) • LaV Anfragebearbeitung • Containment • Definition • Test • Nutzbarkeit und Nützlichkeit von Views Felix Naumann, VL Informationsintegration, WS 05/06

  26. LaV – Anfrageumschreibungen • Gegeben • Anfrage Q (query) • Sicht V (view) • Fragen • Ist Ergebnis von V identisch dem Ergebnis von Q? • Kurz: Ist V äquivalent zu Q, V = Q ? • Rückführung auf „Enthalten sein“ (containment) • Ist das Ergebnis von V in Q enthalten? • Kurz: Ist V in Q enthalten, V  Q ? • Denn • V  Q, Q  V  V = Q Quelle: VL Data Warehousing, Prof. Ulf Leser, HU Berlin Felix Naumann, VL Informationsintegration, WS 05/06

  27. LaV – Anfrageumschreibungen • Query containment (Anfrage-“Enthaltensein“) • Sei S ein Schema. Seien Q und Q‘ Anfragen gegen S. • Eine Instanz von S ist eine beliebige Datenbank D mit Schema S. • Das Ergebnis einer Anfrage Q gegen S auf einer Datenbank D, geschrieben Q(D), ist die Menge aller Tupel, die die Ausführung von Q in D ergibt. • Q‘ ist contained (enthalten) in Q, geschrieben Q‘Q, gdw. Q‘(D)  Q(D) für jedes mögliche D. Quelle: VL Data Warehousing, Prof. Ulf Leser, HU Berlin Felix Naumann, VL Informationsintegration, WS 05/06

  28. LaV – Anfrageumschreibungen • Query equivalence (Anfrageäquivalenz) • Q ist äquivalent mit Q‘, geschrieben Q=Q‘, gdw. Q(D)  Q‘(D) und Q(D)  Q‘(D) für jede mögliche Datenbank D. • Wichtig • Es zählt das Ergebnis einer Anfrage, nicht die Syntax. Felix Naumann, VL Informationsintegration, WS 05/06

  29. LaV – Beispiele SELECT K.titel, L.prof, K.kurs_id, K.univ FROM Lehrt L, Kurs K WHERE L.kurs_id = K.kurs_id AND K.univ = „Humboldt“ AND L.univ = „Humboldt“ AND K.titel LIKE „%VL_%“ ???  SELECT K.titel, L.prof, K.kurs_id, K.univ FROM Lehrt L, Kurs K WHERE L.kurs_id = K.kurs_id AND K.univ = „Humboldt“ AND L.univ = „Humboldt“ Felix Naumann, VL Informationsintegration, WS 05/06

  30. LaV – Beispiele SELECT K.titel, K.kurs_id FROM Kurs K AND K.univ = „Humboldt“ AND K.titel LIKE „%VL_%“ SELECT K.titel, K.kurs_id FROM Kurs K AND K.univ = „Humboldt“ ???   ??? SELECT K.titel, K.univ FROM Kurs K AND K.univ = „Humboldt“ AND K.titel LIKE „%VL_%“ SELECT K.titel FROM Kurs K AND K.univ = „Humboldt“ Felix Naumann, VL Informationsintegration, WS 05/06

  31. LaV – Beispiele • Prüfung von containment durch Prüfung aller möglichen Datenbanken? • Zu complex! • Prüfung von containment durch Existenz eines containment mapping. • NP-vollständig in |Q|+|Q‘| nach [CM77] • Mehrere Algorithmen Quelle 3: CREATE VIEW Hum-Kurse AS SELECT K.titel, K.univ FROM Lehrt L, Kurs K WHERE L.kurs_id = K.kurs_id AND K.univ = „Humboldt“ AND L.univ = „Humboldt“ ???  Quelle 5: CREATE VIEW Kurse2 AS SELECT K.titel, K.univ FROM Kurs K AND K.univ = „Humboldt“ Felix Naumann, VL Informationsintegration, WS 05/06

  32. Datalog Notation • Im Folgenden: Nur Konjunktive Anfragen • Nur Equijoins und Bedingungen mit =,<,> zw. Attribut und Konstanten • Kein NOT, EXISTS, GROUP BY, , X>Y, ... • Schreibweise: Datalog / Prolog • SELECT Klausel • Regelkopf, Exportierte Attribute • FROM Klausel • Relationen werden zu Prädikaten • WHERE Klausel • Joins werden durch gleiche Attributnamen angezeigt • Bedingungen werden explizit angegeben Felix Naumann, VL Informationsintegration, WS 05/06

  33. SQL – Datalog SELECT WHERE Joins FROM SELECT S.price, L.region_name FROM sales S, time T, ... WHERE S.day_id = T.day_id AND S.product_id = P.product_id AND S.shop_id = L.shop_id AND L.shop_id = 123 AND T.year > 1999 q(P,RN) :- sales(SID,PID,TID,RID,P,...), time(TID,D,M,Y), localization(LID,SN,RN), product(PID,PN,PGN), Y > 1999, SID = 123 Felix Naumann, VL Informationsintegration, WS 05/06

  34. Query Containment • A query p is contained in a query u, pu, iff all tuples computed by p are also computed by u for every DB. • Beispiele (Regelkopf weggelassen) • map(Mn,Ms)  map(Mn,Ms); • map(Mn,Ms), Mn = ‘HGM’  map(Mn,Ms); • map(Mn,Ms), Ms<500  map(Mn,Ms); • map(Mn,Ms), clone(Mn,Cn,-)  map(Mn,Ms); • clone(Mn,Cn,Cs), clone(Mn,Cn,Cs)  clone(Mn,Cn,Cs); Quelle: Folien Ulf Leser Felix Naumann, VL Informationsintegration, WS 05/06

  35. map(Mn,Ms),clone(Mn,Cn,-,-)  map(Mn,Ms); Beweis für Query Containment • p  u gdw ein containment mapping von u nach p existiert. • Containment mapping: • h: sym(u) → sym(p) (Abbildung der Symbole) • CM1: Jede Konstante in u wird auf die gleiche Konstante in p abgebildet. • CM2: Jede exportierte Variable in u wird auf eine exportierte Variable in p abgebildet. • CM3: Jedes Literal (Relation) in u wird auf mindestens ein Literal in p abgebildet • CM4: Die Bedingungen von p implizieren die Bedingungen von u • Beweis: [CM77] Quelle: Folien Ulf Leser Felix Naumann, VL Informationsintegration, WS 05/06

  36. Finden von Containment Mappings • Problem ist NP vollständig • Exponentiell in der Anzahl der Literale • Beweis: Reduktion auf „Exakt Cover“ • Also: Alles ausprobieren • Aufbau eines Suchbaums • Jede Ebene entspricht einem Literal • Auffächerung nach möglichen CMs • Algorithmus • Nicht hier • siehe DWH VL Ulf Leser Felix Naumann, VL Informationsintegration, WS 05/06

  37. CM Beispiele Quelle: DWH VL Leser Felix Naumann, VL Informationsintegration, WS 05/06

  38. CM Beispiele Quelle: DWH VL Leser Felix Naumann, VL Informationsintegration, WS 05/06

  39. Erzeugung der Anfragen Beobachtung: Interpretation als containment name(spendenDB.firmen)  orgname(haushaltDB.stadtHaushalt.org) name,spendeID,betrag(spendenDB.firmen  spendenDB.spenden)  orgname,spendeID,menge(haushaltDB.stadtHaushalt.org.einnahmen  haushaltDB.stadtHaushalt.buchungen) Felix Naumann, VL Informationsintegration, WS 05/06

  40. Literatur • Gute Zusammenfassung für LaV und weiterführende Literatur: • [Hal01] Alon Y. Halevy: Answering queries using views: A survey, in VLDB Journal 10: 270-294, 2001. • Weitere Literatur • [Ull97] Jeffrey D. Ullman: Information Integration Using Logical Views. ICDT 1997: 19-40 • [CM77] Ashok K. Chandra and Philip M. Merlin. Optimal implementation of conjunctive queries in relational data bases. In Conference Record of the Ninth Annual ACM Symposium on Theory of Computing, pages 77-90, Boulder, Colorado, 2-4 May 1977. • [LMSS95] Alon Y. Levy, Alberto O. Mendelzon, Yehoshua Sagiv, Divesh Srivastava: Answering Queries Using Views. PODS 1995: 95-104 Felix Naumann, VL Informationsintegration, WS 05/06

  41. name fach Arbeitet Vertiefung name name Betreut Prof stud bereich lehrt Eingeschrieben eval Kurs sem sem titel kurs_id LaV – Beispiel Globales Schema Prof(name, bereich) Kurs(kurs_id, titel, univ) Lehrt(prof,kurs_id, sem, eval, univ) Eingeschrieben(stud, kurs_id, sem) Vertiefung(stud, fach) Arbeitet(prof, fach) Betreut(prof, stud) Felix Naumann, VL Informationsintegration, WS 05/06

More Related