Chapter 1 XML Design for Data

Slides:



Advertisements
Similar presentations
Database Lecture Notes Mapping ER Diagrams to Tables 2 Dr. Meg Murray
Advertisements

XML Document Type Definitions ( DTD ). 1.Introduction to DTD An XML document may have an optional DTD, which defines the document’s grammar. Since the.
DTDs : definitions. Defining Elements PCDATA: Parsed character data i.e., any characters without further XML structure.
Document Type Definition DTDs CS-328. What is a DTD Defines the structure of an XML document Only the elements defined in a DTD can be used in an XML.
A Technical Introduction to XML Transparency No. 1 XML quick References.
Semi-structured Data. Facts about the Web Growing fast Popular Semi-structured data –Data is presented for ‘human’-processing –Data is often ‘self-describing’
Declare A DTD File. Declare A DTD Inline File For example, use DTD to restrict the value of an XML document to contain only character data.
Introduction to XML This material is based heavily on the tutorial by the same name at
1 Advanced Topics XML and Databases. 2 XML u Overview u Structure of XML Data –XML Document Type Definition DTD –Namespaces –XML Schema u Query and Transformation.
CIS 270—App Dev II Big Java Chapter 22 Relational Databases.
Chapter 10: XML.
Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA.
XML Structures For Existing Databases Ref: 106.ibm.com/developerworks/xml/library/x-struct/
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
XML (2) DTD Sungchul Hong.
XML. 2 XML- Some Links XML Tutorials – Some Links me=htmlhttp://
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
Of 33 lecture 3: xml and xml schema. of 33 XML, RDF, RDF Schema overview XML – simple introduction and XML Schema RDF – basics, language RDF Schema –
XML - DTD Week 4 Anthony Borquez. What can XML do? provides an application independent way of sharing data. independent groups of people can agree to.
 XML DTD and XML Schema Discussion Sessions 1A and 1B Session 2.
XML Introduction. What is XML? XML stands for eXtensible Markup Language XML stands for eXtensible Markup Language XML is a markup language much like.
1/11 ITApplications XML Module Session 3: Document Type Definition (DTD) Part 1.
Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema.
Chapter 23 XML. 2 Introduction  XML: eXtensible Markup Language (What is a Markup language?)  Defined by the WWW Consortium (W3C)  Originally intended.
XML – A Quick Introduction Kerry Raymond (stolen from others)
1 Chapter2. XML Structures for Existing Databases Database 연구실 석사 1 학기 편선경.
INFSY 547: WEB-Based Technologies Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Understand Primary, Foreign, and Composite Keys Database Administration Fundamentals LESSON 4.2.
DTD Document Type Definition. Agenda Introduction to DTD DTD Building Blocks DTD Elements DTD Attributes DTD Entities DTD Exercises DTD Q&A.
Copyright 2002, Ronald Bourret, XML-DBMS Middleware for XML and databases Ronald Bourret O'Reilly Open.
Chapter 4, Part A: Logical Database Design and the Relational Model
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 4: PART C LOGICAL.
XML Databases Presented By: Pardeep MT15042 Anurag Goel MT15006.
CS 480: Database Systems Lecture 26 March 18, 2013.
IS432 Semi-Structured Data
Order Database – ER Diagram
How to: SQL By: Sam Loch.
Chapter 1 Introduction.
Database Management Systems II
Order Database – ER Diagram
Chapter 17 Data Warehousing, Archival, and Repositories
Basic Database Design COSC 2328 – Web Programming.
Normalization Karolina muszyńska
Database Systems Week 12 by Zohaib Jan.
Order Database – ER Diagram
Order Database – ER Diagram
Document Type Definition DTDs
MIS5101: Business Intelligence Relational Data Modeling
Example Question–Is this relation Well Structured? Student
CHAPTER 9 JAVA AND XML.
Managing XML and Semistructured Data
CHAPTER 7: ADVANCED SQL.
Web Programming Maymester 2004
Insert, Update, Delete Manipulating Data.
MIS2502: Data Analytics Converting ERDs to Schemas
RELATIONAL DATABASES AND XML
ece 720 intelligent web: ontology and beyond
Order Database – ER Diagram
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Lecture 9: The E/R Model II
Order Database – ER Diagram
Lecture 9: XML Monday, October 17, 2005.
ER Diagram Master How to use this template
DTD (Document Type Definition)
A Very Brief Introduction to Relational Databases
MIS2502: Data Analytics Relational Data Modeling 3
Lecture 11: XML and Semistructured Data
Document Type Definition (DTD)
XML IST 421.
Presentation transcript:

Chapter 1 XML Design for Data Database Lab 석사1학기 강 나 영

XML for Text vs.XML for Data If the markup were removed, the text of paragraph itself would still have the same meaning outside the XML document. The order of the information is of critical importance to understanding its meaning. XML for Data Data can be represented in a number of different ways and still have the same functionality.

Representing Data in XML Element Content Models Element-only content Mixed content Text-only content The EMPTY model The Ant model Using Attributes Other Considerations Audience Performance Data modeling vs. representation modeling

Element Content Models(1) Element-only content Elements may only contain other elements. ex) Mixed Content Elements may contain zero or more instances of list of elements. <!ELEMENT Invoice (Customer, LineItem+)> <Invoice> <Customer /> <LineItem /> </Invoice> <!ELEMENT Invoice (#PCDATA | LineItem | Custome)*> <Invoice> This is the invoice for <Customer>Kevin Williams</Customer> </Invoice>

Element Content Models(2) Text-only Content Elements may only contain text string. ex) One way to include data points in our documents. EMPTY Content An element cannot contain anything at all. <!ELEMENT Customer (#PCDATA)> <Customer>Kevin Williams</Customer> <!ELEMENT Customer EMPTY> <Customer />

Element Content Models(3) ANY Content Any element or text may appear inside the element. ex) or ※Mixed content model & ANY content model ; too permissive for data <!ELEMENT Customer ANY> <Customer>Kevin Williams</Customer> <Customer> <Customer>Kevin Williams</Customer> </Customer>

Using Attributes The other way to represent data points. ex) <!ELEMENT Customer EMPTY> <!ATTLIST Customer FirstName CDATA #REQUIRED LastName CDATA #REQUIRED> <Customer FirstName=“Kevin” LastName=“Williams”/>

Other Considerations(1) Audience Dose the document need to be human-readable? Is the document intended primarily for display or for processing? How many consumers will be processing the document? Is the document intended to operate under a standard that constrains the allowable structure? Performance ex) <Invoice customerName=“Kevin Williams”> <LineItem productName=“Grommets (2 inch)” quantity=“17” price=“0.10” /></Invoice> <I c=“c17”><L p=“p22” q=“17” pr=“.1” /></I>

Other Considerations(2) Data Modeling vs. Representation Modeling Representation Modeling ex) <Invoice> Widgets, Inc. Invoice Customer: <customerName>Kevin Williams</customerName> <orderAddress>742 Evergreen Terrace</orderAddress> Ship to: <shipName>Kevin Williams</shipName> <shipAddress>742 Evergreen Terrace</shipAddress> Shipper: <shippingCompany>FedEx</shoppingCompany> Item Code Description Quantity price Total <LineItem> <itemCode>1A2A3AB</itemCode> <itemDescription>Widget(3 inch)</itemDescription> <quantity>17</quantity> <price>$0.10</price> <linePrice>$1.70</linePrice> </LineItem> </Invoice>

Other Considerations(2) Data Modeling vs. Representation Modeling Data Modeling ex) <Invoice customerName=“Kevin Williams” <Address addressType=“billing” street=“742 Evergreen Terrace”/> addressType=“shipping” <LineItem itemCode=“1A2A3AB” itemDescription=“Widget(3 inch)” quantity=“17” price=“0.10” currency=“USD”/> </Invoice>

Mapping Between RDBMS and XML Structures(1) When moving data between XML form and a relational database a table ↔ an element with element-only content ex) Within <Customer> element, the details about the customer can be represented in one of two ways. Using text-only elements. Using attributes. CREATE TABLE Customer ( firstName varchar(50), lastName varchar(50), mailingAddress varchar(50), mailingCity varchar(60), mailingState varchar(3))

Mapping Between RDBMS and XML Structures(2) 1) Elements ex) <!ELEMENT Customer (firstName, lastName, mailingAddress, mailingCity, mailingState)> <!ELEMENT firstName (#PCDATA)> <!ELEMENT lastName (#PCDATA)> <!ELEMENT mailingAddress (#PCDATA)> ‥‥ <Customer> <firstName>Kevin</firstName> <lastName>Williams</lastName> <mailingAddress>742 Evergreen Terrace</mailingAddress> ‥‥ </Customer> When representing data in an XML document, any element that is defined as having text-only content using the #PCDATA keyword will correspond to a column in a relational database.

Mapping Between RDBMS and XML Structures(3) 2) Attributes Elements that represent tables have attributes associated with them that represent columns. ex) <!ELEMENT Customer EMPTY> <!ATTRIST Customer firstName CDATA #REQUIRED lastName CDATA #REQUIRED mailingAddress CDATA #REQUIRED ‥‥ <Customer firstName=“Kevin” lastName=“Williams” mailingAddress=“742 Evergreen Terrace” ‥‥ />

Mapping Between RDBMS and XML Structures(4) Data Points There are two primary design strategies that may be used to represent column s as XML structures. Elements, which are nested as children of the element that represents the grouping of information. Attributes, which are added to the element that represents the grouping of information. ex) Widgets, Inc. Invoice Customer: Kevin Williams 742 Evergreen Terrace Ship to: Kevin Williams Shipper: FedEx Item Code Description Quantity price Total 1A2A3AB Widget(3 inch) 17 $0.10 $1.70

Mapping Between RDBMS and XML Structures(5) 1) Our Invoice Using Elements ex) <!ELEMENT Invoice (customerName, billingAddress, billingCity, billingState, ‥‥, LineItem+)> <!ELEMENT customerName (#PCDAYA)> <!ELEMENT billingAddress (#PCDATA)> ‥‥ <!ELEMENT LineItem (itemCode, itemDescription,quantity,price)> <!ELEMENT itemCode (#PCDATA)> <!ELEMENT itemDescription (#PCDATA)> [Ch02_ex1.dtd] <?xml version=“1.0” ?> <!DOCTYPE Invoice SYSTEM http://myserver/xmldb/ch02_ex1.dtd”> <Invoice> <customerName>Kevin Williams</customerName> ‥‥ <LineItem> <itemCode>1A2A3AB</itemCode> [Ch02_ex1.xml]

Mapping Between RDBMS and XML Structures(6) 2) Our Invoice Using Attributes ex) <!ELEMENT Invoive (LineItem+)> <!ATTRIST Invoice customerName CDATA #REQUIRED billingAddress CDATA #REQUIRED ‥‥ > <!ELEMENT LineItem EMPTY> <!ATTRIST Lineitem itemCode CDATA #REQUIRED itemDescription CDATA #REQUIRED [Ch02_ex2.dtd] <?xml version=“1.0” ?> <!DOCTYPE Invoice SYSTEM http://myserver/xmldb/ch02_ex2.dtd”> <Invoice customerName=“Kevin Williams” ‥‥ /> <LineItem itemCode=“1A2A3AB” </Invoice> [Ch02_ex2.xml]

Mapping Between RDBMS and XML Structures(7) 3) Comparing the two Approaches Readability Compatibility with database Strong data typing Programming complexity DOM (Document object Model) SAX (Simple API for XML) Document size

Mapping Between RDBMS and XML Structures(8) Relationships ex) Invoice LineItem CREATE TABLE Invoice ( invoiceID integer PRIMARY KEY, customerID integer, ‥‥ ) CREATE TABLE LineItem ( lineItem integer, invoiceID integer, ‥‥ CONSTAINT fk_LineItemInvoice FOREIGN KEY (invoiceID) REFERENCES Invoice (invoiceID)) invoiceID customerID orderDate shipDate lineItemID invoiceID productDescription quantity unitprice

Mapping Between RDBMS and XML Structures(9) 1) Containment One-to-one and one-to-many relationships are best represented by containment ex) <!ELEMENT Invoive (LineItem+)> <!ATTRIST Invoice orderDate CDATA #REQUIRED shipDate CDATA #REQUIRED> <!ELEMENT LineItem EMPTY> <!ATTRIST Lineitem productDescription CDATA #REQUIRED ‥‥ >

Mapping Between RDBMS and XML Structures(10) 2) More Complex Relationships - Pointers Invoice invoiceID customerID orderDate shipDate LineItem lineItemID invoiceID productID quantity unitprice Product productID productShortName productDescription

Mapping Between RDBMS and XML Structures(11) 2) More Complex Relationships - Pointers ex) ch02_ex3.dtd <!ELEMENT orderData (Invoice+, Product+)> <!ELEMENT Invoive (LineItem+)> <!ATTRIST Invoice orderDate CDATA #REQUIRED shipDate CDATA #REQUIRED> <!ELEMENT LineItem EMPTY> <!ATTRIST Lineitem productIDREF IDREF #REQUIRED ‥‥ > <!ELEMENT Product EMPTY> <!ATTRIST Product productID ID #REQUIRED

Mapping Between RDBMS and XML Structures(12) ex) ch02_ex3.xml <?xml version=“1.0” ?> <!DOCTYPE Invoice SYSTEM http://myserver/xmldb/ch02_ex3.dtd”> <orderData> <Invoice orderDate=“7/23/2000” shipData=“7/28/2000”> <LineItem productIDREF=“prod1” ‥‥ /> /Invoice> ‥‥ <Product productID=“prod1” productShortName=“Widgets (3 inch)” </orderData>

Mapping Between RDBMS and XML Structures(13) 3) More Complex Relationships - Contianments ex) ch02_ex4.dtd <!ELEMENT orderData (Invoice+)> <!ELEMENT Invoive (LineItem+)> <!ATTRIST Invoice orderDate CDATA #REQUIRED shipDate CDATA #REQUIRED> <!ELEMENT LineItem (Product)> <!ATTRIST Lineitem quantity CDATA #REQUIRED ‥‥ > <!ELEMENT Product EMPTY> <!ATTRIST Product productShortName CDATA #REQUIRED

Mapping Between RDBMS and XML Structures(14) ex) ch02_ex4.xml <?xml version=“1.0” ?> <!DOCTYPE Invoice SYSTEM http://myserver/xmldb/ch02_ex4.dtd”> <orderData> <Invoice orderDate=“7/23/2000” shipData=“7/28/2000”> <LineItem quantity=“17” uniPrice=“0.10”> <Product productShortName=“Widgets (3 inch)” ‥‥ /> </LineItem> </Invoice> ‥‥ </orderData>