Databases and Information Systems 2
Transcription
Databases and Information Systems 2
Databases and Information Systems 2 Prof. Dr. Stefan Böttcher Fakultät EIM, Institut für Informatik Universität Paderborn SS 2007 Contents: • Why mobile XML database systems ? • New database technology for mobile XML database systems (and other DBS) • Further topics (e.g. web technology, middleware, EJB, …) Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 1 Why XML ? <20 % of data stored in relational DBs >80 % of data stored in documents - more or less structured semi-structured Structure supports retrieval of data and knowledge XML used as standard data exchange protocol for middleware (SOAP), web services, … product catalogs (BMEcat), … Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 2 1 XML in relational databases? Assume you have a relational database system. How would you use it in XML-based applications, i.e. applications that want to exchange, read, transform, … XML data? exercise Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher XML - Introduction / 3 database mappings • mapping XML + XPath to relational databases + datalog • mapping databases to XML ( • flat database DBIS 2 ) XML mapping • hierarchical database XML mapping • limitations of reverse mappings Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 4 2 Implementing XML by relational databases • many different approaches one based on label, first-child (fc) and next-sibling(ns) <Auftrag> <Kunde>Meier</Kunde> <PC>pc500</PC> </Auftrag> 1 root 2 Auftrag 3 Kunde 5 PC 4 Meier 6 pc500 Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher Introduction / 5 - Implementing XML by relational databases • many different approaches one based on label, first-child (fc) and next-sibling(ns) <Auftrag> <Kunde>Meier</Kunde> <PC>pc500</PC> </Auftrag> 1 root 2 Auftrag 3 Kunde 5 PC 4 Meier 6 pc500 label( ID, Label) fc(P,FC) ID Label(ID) ID fc(ID) 1 root 1 2 2 Auftrag 2 3 3 Kunde 3 4 4 Meier 5 6 5 PC 6 pc500 ns(ID,NS) ID ns(ID) 3 5 Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 6 3 Implementing XML axes by Datalog programs following-sibling(X,Y) = ns+(X,Y) ; // implementation in datalog as usual following-sibling(X,Y) :- ns( X, Y ). following-sibling(X,Y) :- ns( X, NS ), following-sibling(NS,Y) . 1 root 2 Auftrag 3 Kunde 5 PC 4 Meier 6 pc500 child(X,Y) :- fc(X,Y) . child(X,Y) :- fc(X,FC) , following-sibling( FC, Y ). ID Label(ID) ID fc(ID) 1 root 1 2 2 Auftrag 2 3 3 Kunde 3 4 4 Meier 5 6 5 PC 6 pc500 ns(ID,NS) ID ns(ID) 3 5 Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 7 Implementing XML axes by Datalog programs // following-sibling(X,Y) = ns+(X,Y) . // implementation in datalog as usual following-sibling(X,Y) :- ns( X, Y ). following-sibling(X,Y) :- ns( X, NS ), following-sibling(NS,Y) . 1 root 2 Auftrag 3 Kunde 5 PC 4 Meier 6 pc500 child(X,Y) :- fc(X,Y) . child(X,Y) :- fc(X,FC) , following-sibling( FC, Y ). // descendant( X, Y ) = child+(X,Y) . descendant(X,Y) :- child( X, Y ). descendant(X,Y) :- child( X, C ) , descendant(C,Y) . Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 8 4 Implementing XML axes by Datalog programs reverse-axis(X,Y) = reverse-axis-1(Y,X) ancestor( D, A ) :- descendant( A, D ) . parent( C, P ) :- child ( P, C ) . parent( A, P ) :- attribute ( P, A ) . parent( N, P ) :- namespace ( P, N ) . Axis-or-self(X,Y) = Axis(X,Y) Axis-or-self(X,Y) = self(X,Y) 1 root 2 Auftrag 3 Kunde 5 PC 4 Meier 6 pc500 self( X, X ). descendant-or-self( A, D ) :- descendant( A, D ). descendant-or-self( A, D ) :- self( A, D ). ancestor-or-self( D, A ) :- ancestor( D, A ). ancestor-or-self( D, A ) :- self( D, A ). Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 9 Implementing XML axes by Datalog programs following::* = ancestor-or-self::* / following-sibling::* / descendant-or-self::* following(X,Y) :- ancestor-or-self(X,A) , following-sibling(A,S) , descendant-or-self(S,Y) . 1 root 2 Auftrag 3 Kunde 5 PC 4 Meier 6 pc500 preceding(X,Y) :- following(Y,X) . Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 10 5 Implementing XPath queries by Datalog queries // Kunde ?- goal(K). goal(K) :- label( R, “root“ ) , descendant( R , K ) , label( K , “Kunde“ ) . Answer: K=3. 1 root 2 Auftrag 3 Kunde 5 PC 4 Meier 6 pc500 (R=1) Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 11 Implementing XPath queries by Datalog queries // Kunde ?- goal(K). goal(K) :- label( R, “root“ ) , descendant( R , K ) , label( K , “Kunde“ ) . Answer: K=3. 1 root 2 Auftrag 3 Kunde 5 PC 4 Meier 6 pc500 (R=1) // Auftrag [ PC ] / Kunde ?- goal2( K ). goal(K) :- label( R, “root“ ) , descendant( R, A ) , child( A, P ) , label( P , "PC" ) , child( A, K ) , label( K , "kunde" ) . (R=1) (A=2) (P=5) (K=3) Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 12 6 Evaluation of XPath implemented by Datalog use fast algorithm for Datalog evaluation, e.g. Process Model, that combines Top-Down selection-first evaluation with set-oriented bottom-up computation only unary and binary base relations subclass of Datalog programs that can be evaluated efficiently Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 13 Limits of implementing XML/XPath by Datalog • updates of XML documents updates of datalog views (o.K.) however: beyond this point: view update problem Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 14 7 Summary: XML/XPath implemented by Datalog • base relations: Label( ID, Label ) , fc( Parent, FirstChild ) , ns( Node, NextSibling ) • recursive deductive database rule systems for following-sibling( Node , FS ) child( Parent, Child ) , descendant( Node, Descendant ) • combination rules for following( Node, Following ) descendant-or-self( Node , DOS ) ancestor-or-self( Node , AOS ) • reverse-axis Datalog rules for ancestor( Node, Ancestor ) parent( Node, Parent ) preceding-sibling( Node, PrecedingSibling ) preceding( Node, Preceding ) Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 15 Commercial XML database systems (1) XML as an extension to an existing relational database - data is already stored in a relational database (e.g. Oracle) - extra data type generates XML doc name = “Meier“ order customer customer address order address Customer name order address Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 16 8 Commercial XML database systems (2) extra columns of type XML document (e.g. Microsoft) + original XML documents can be stored + search in stored XML documents + XPath queries are transformed into internal queries date orders XML document containing orders of date doc name = “Meier“ order … customer customer address order … address … Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 17 Commercial XML database systems (3) hybrid XML database system (e.g. IBM DB2 Universal Server): - relational data stored in relational database - XML data stored in separate storage + both parts of the database accessable via join queries + effizient access in the relational part of the database + external XML documents can be stored + search in stored XML documents Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 18 9 Why mobile XML database systems? increasing market share of mobile devices (cellulars, PDAs, …) using data intensive applications in mobile environments requires involving database technology for mobile devices current middleware data exchange format is XML XML data exchange required payment, contracts, … via or between mobile devices demands data persistence and atomic contracts involving or between mobile devices Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 19 Challenges of mobile XML databases Assume you want to port XML-based data intensive applications to mobile devices. What are the typical database system challenges (in contrast to, i.e. omitting challenges to network technology) ? Exercise: 1. describe goals "a mobile database system should … <Goal X> " 2. for each goal think of and discuss the technical requirements "in order to achieve X, the database system should achieve/guarantee Y " 3. for each goal think of and discuss possible solution ideas "in order to meet requirement Y, the database system could do … " Databases and Information Systems 2 - SS 20 07 - Prof. Dr. Stefan Böttcher - Introduction / 20 10