IS432 Semi-Structured Data Lecture 6: XML Mapping to Object/Relational Databases Dr. Gamal Al-Shorbagy
----------------------------- Table Based Mapping <A> <B> <C>ccc</C> <D>ddd</D> <E>eee</E> </B> <C>fff</C> <D>ggg</D> <E>hhh</E> </A> Table A ------------ C D E ----------------------------- ccc ddd eee fff ggg hhh
Table Based Mapping <Tables> <Table_1> <Row> <Column_1>...</Column_1> ... <Column_n>...</Column_n> </Row> ... <Column_1>...</Column_1> </Table> <Tables> <Table_1> <Row> <Column_1>...</Column_1> ... <Column_n>...</Column_n> </Row> </Table_1> <Table_n> <Column_m>...</Column_m> </Table_n> </Tables>
Table Based Mapping Advantages Disadvantages Simplicity Easy to write code Easy to transfer data between XML and Database Disadvantages Too simple to work with complex XML documents Does not preserve physical structure Such as character and entity references, CDATA sections, Character encodings The document type or DTD Comments, or processing instructions.
XML-Object-Relational Mapping RDB <XML/> Instance
XML-Object-Relational Mapping
XML-Object-Relational Mapping Instance RDB DTD DTD Object Schema Relational Schema
Object Relational Mapping
Object Relational Mapping
Object Relational Mapping Object SalesOrder{ number =1234; customer = “Abdullah”; date = 2012.07.15; items = {pointer to Item objects}; } Object Item{ number =1; item = “CD-ROM”; Quantity = 1; price = 25; } Object Item{ number = 2; item = “DRAM”; Quantity = 1; price = 65; }
Object Relational Mapping SalesOrder number customer date 1234 Abdullah 2012.07.15 …. Items sonumber number Item quantity price 1234 1 CD-ROM 25 2 DRAM 65
Sub Elements - Composition
Element Occurrence Constraints
Object-Relational Mapping
Mapping Complex Content Models <!ELEMENT A (B?, (C | ((D | E | F | G)*, (H | I)+, J?)))>
Mapping Sequences
Mapping Choices
Mapping Repeated Children
Mapping Groups
Mapping Attributes
Mapping Attributes
Take Home Quiz Create XML Schema/XML to store data in following relational database tables. Students Name ID Book_ID Ahmad 0001 1111 Ali 0002 1112 Hassan 0003 1113 Books Book_ID Title Author 1111 XML for Dummies Ahmad Ali 1112 Semi Structured Data 1113 XML in Summer
Thanks