1 / 15

CS360 Project #2 An XML storing & querying system

CS360 Project #2 An XML storing & querying system. 2012. 5. 10. TA. Min-Joong Lee (mjlee@islab.kaist.ac.kr, x7837). Outline. Implement an XML storing & querying system based on an RDBMS A program to store a given XML document into relations in an RDBMS Use MySQL 5.5.23 (and JDBC 5.1.20)

ailis
Télécharger la présentation

CS360 Project #2 An XML storing & querying system

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. CS360 Project #2 An XML storing & querying system 2012. 5. 10. TA. Min-Joong Lee(mjlee@islab.kaist.ac.kr, x7837)

  2. Outline • Implement an XML storing & querying system based on an RDBMS • A program to store a given XML document into relations in an RDBMS • Use MySQL 5.5.23 (and JDBC 5.1.20) • Use DOM Parser • Import org.w3c.dom.* and javax.xml.parsers.* • A simple XPath query processor • Cover a small part of the full XPath query functions CS360 Project #2

  3. Requirement • Storing an XML document into relations in an RDBMS • Input • an XML document • Database Name • “XML_DB” • Relational schema • Edge (source, target, name, flag) • Value(vid, value)  Edge approach with a separated value table > java XMLToDB phonebook.xml CS360 Project #2

  4. Requirement • A simple XPath query processor • Input • An XPath query • Output • Translated SQL queries and the XML result-“[student ID]_SQL.txt” file including translated SQL queries. • -“[student ID].txt“ file including the reconstructed XML result. > java XPathQProcessor /phonebook/person[name=”Mary”] CS360 Project #2

  5. Requirement > java XPathQProcessor /phonebook/person[name=”Mary”] • -“[student ID]_SQL.txt” file including translated SQL queries. select target from Edge where name=’phonebook’ and source=0 select target from Edge where name=’person’ and source=1 select target from Edge where name=’name’ and (source=2 or source=11) select target from Edge where (source=3 or source=12) and flag=1 select vid from Value where (vid=4 or vid=13) and value=’Mary’ select source from Edge where target=13 select source from Edge where target=12 select * from Edge where source=11 select value from Value where vid in (select target from Edge where source in (select target from Edge where source=11) ) CS360 Project #2

  6. Requirement > java XPathQProcessor /phonebook/person[name=”Mary”] • -“[student ID].txt“ file including the reconstructed XML result. <person> <name>Mary</name> <address>4713 Fruitdale Ave.</address> <homephone>538-0922</homephone> </person> CS360 Project #2

  7. Requirement • A simple XPath query processor • Restricted syntax • No recursion, no attribute • Covers only abbreviated syntaxes, and supports • 1) Parent-child relationship, ‘/’ • e.g. /phonebook/person/name • 2) Ancestor-descendant relationship, ‘//’ • e.g. //person/officephone • 3) Child-parent relationship, ‘..’ • e.g. //person[name=“Mary”]/../officephone • 4) Exact matching, [=] • e.g. /phonebook/person[name=“Peter”] XPath Specification http://www.w3c.org/TR/xpath CS360 Project #2

  8. An XML document • <phonebook> • <person> • <name>Peter</name> • <address>4711 Fruitdale Ave.</address> • <officephone>533-9589</officephone> • <officephone>533-9590</officephone> • </person> • <person> • <name>Mary</name> • <address>4713 Fruitdale Ave.</address> • <homephone>538-0922</homephone> • </person> • <phonebook> phonebook An example document person person address name officephone name address homephone officephone Peter 4711 Fruitdale Ave. 533-9589 533-9590 Mary 4713 Fruitdale Ave. 538-0922 Edge Labeled Tree structuredXML document CS360 Project #2

  9. Edge Approach (from class) • What is Edge Approach? • Store all edges of the tree that represents an XML document in a single table Edge phonebook 0 1 person person 2 address name officephone officephone 3 5 7 9 Peter 4711 Fruitdale Ave. 533-9589 533-9590 4 6 8 10 Node order : left-deep traversal Flag : 0 for reference type 1 for string CS360 Project #2

  10. Edge Approach(from class) • A separated value table • Only contains leaf nodes • Assume all value is string Value phonebook 0 1 person person 2 address name officephone officephone 3 5 7 9 Peter 4711 Fruitdale Ave. 533-9589 533-9590 4 6 8 10 CS360 Project #2

  11. Edge Approach(from ref. paper) Edge phonebook 0 person 1 person 2 address name officephone officephone 3 4 5 6 Peter 4711 Fruitdale Ave. 533-9589 533-9590 Value Node order : left-deep traversal Flag : Not use CS360 Project #2

  12. DOM Parser … Import org.w3c.dom.* Import javax.xml.parsers.* … DocumentBuilderparser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = parser.parse(new File("example.xml")); NodeList children = doc.getChildNodes(); Node nextSibling = doc.getNextSibling(); CS360 Project #2

  13. XPath Query Example • /Company/Division/Division_name • //Person[Name=“Tom”]/../Division_name <Company> <Division> <Division_name>Marketing</Division_name> <Person> <Name> Tom </Name> <Age> 29 </Age> </person> <Person> <Name> Mary </Name> <Age> 35 </Age> </person> </Division> </Company> XML Document <Division_name>Marketing</Division_name> CS360 Project #2

  14. XPath Query Example • /Company/Division/Person[Name=“Tom”] <Company> <Division> <Division_name>Marketing</Division_name> <Person> <Name> Tom </Name> <Age> 29 </Age> </person> <Person> <Name> Mary </Name> <Age> 35 </Age> </person> </Division> </Company> XML Document <Person> <Name> Tom </Name> <Age> 29 </Age> </person> CS360 Project #2

  15. Submission • Due date • May 25th , 2012, 23:59:59 Midnight (20% penalty per day) • Weight: 13% • Send an e-mail to the TA with the attachment of Zip file containing Java source code, library, and README file • Make the title of an e-mail as follows : [CS360 Project#2] Your Student ID, Your Name • Make the title of Zip file corresponding to your student id: e.g., 20081234.zip • TA’s email(for submission) • mjlee@islab.kaist.ac.kr CS360 Project #2

More Related