Download - XML and Databases
![Page 1: XML and Databases](https://reader031.vdocument.in/reader031/viewer/2022020721/568131bb550346895d9823b7/html5/thumbnails/1.jpg)
XML and Databases
![Page 2: XML and Databases](https://reader031.vdocument.in/reader031/viewer/2022020721/568131bb550346895d9823b7/html5/thumbnails/2.jpg)
Data and Document
• There are really at least two distinct XML uses– XML to describe Documents– XML to describe Data
![Page 3: XML and Databases](https://reader031.vdocument.in/reader031/viewer/2022020721/568131bb550346895d9823b7/html5/thumbnails/3.jpg)
Document vs Data
XML for documents describes complex document structures: many elements with mixed content data types usually just text
Data XML, simpler describing data structure, No or little mixed content: data types varied and important
Document processing
Machine to machine communication
![Page 4: XML and Databases](https://reader031.vdocument.in/reader031/viewer/2022020721/568131bb550346895d9823b7/html5/thumbnails/4.jpg)
XML Data
• Xml for data is usually simpler—more straight forward in structure: less hierarchical levels, no, or very few mixed elements
• It is meant to be generated and read by applications
• Data types are more important—thus the use of schemas rather than DTDs
![Page 5: XML and Databases](https://reader031.vdocument.in/reader031/viewer/2022020721/568131bb550346895d9823b7/html5/thumbnails/5.jpg)
Reasons for XML
• Explosion in the need to share data over the Internet from enterprise databases
• Different database softwares, application softwares, incompatible data schemas
• XML provides an easily managed format for universal communication
![Page 6: XML and Databases](https://reader031.vdocument.in/reader031/viewer/2022020721/568131bb550346895d9823b7/html5/thumbnails/6.jpg)
Universal Communication
Application and platform independent data format
Unicode Multilanguage support
Data logic separate from presentation logic
![Page 7: XML and Databases](https://reader031.vdocument.in/reader031/viewer/2022020721/568131bb550346895d9823b7/html5/thumbnails/7.jpg)
Importance to Database
• David Kroenke* lists these ways in which XML is important for databases– Standard means for representing domains– Standard means for expressing database
views– Clean separation of structure, content and
materialization– Facility for document validity checking– Industry standards for document types*Kroenke, David Database Processing, Eighth Edition: Prentice Hall, NJ, 2001,
p 432
![Page 8: XML and Databases](https://reader031.vdocument.in/reader031/viewer/2022020721/568131bb550346895d9823b7/html5/thumbnails/8.jpg)
Issues
• XML does not always translate well to relational data models
• XML has a primarily hierarchical structure
• Some sort of “Data Mapping” must occur
![Page 9: XML and Databases](https://reader031.vdocument.in/reader031/viewer/2022020721/568131bb550346895d9823b7/html5/thumbnails/9.jpg)
Data Mapping
Database server SQL
Mapping to XML
XML application
![Page 10: XML and Databases](https://reader031.vdocument.in/reader031/viewer/2022020721/568131bb550346895d9823b7/html5/thumbnails/10.jpg)
Approaches to Data Mapping
• Result set mapping—maps the XML to the result set of an SQL Query. (A row element is created for each record. Each column becomes an element or attribute)
• Schema mapping—the database structure is generated to and from XML Schema (we will cover this more later)
![Page 11: XML and Databases](https://reader031.vdocument.in/reader031/viewer/2022020721/568131bb550346895d9823b7/html5/thumbnails/11.jpg)
Commercial Database Support
• SQL Server—can generate XML from SQL and can update tables from XML files.
• Oracle 9-I includes XSU (XML SQL Utility that will– Generate XML based on SQL queries– Extract data from XML for insert or
update
![Page 12: XML and Databases](https://reader031.vdocument.in/reader031/viewer/2022020721/568131bb550346895d9823b7/html5/thumbnails/12.jpg)
XML Databases
• There has been some talk of creating XML databases—that is a database whose native format is XML and which processes queries with XPath and XQuery
• There has also been some movement to include XML as a native Data type in Relational databases
![Page 13: XML and Databases](https://reader031.vdocument.in/reader031/viewer/2022020721/568131bb550346895d9823b7/html5/thumbnails/13.jpg)
The Gist
• XML is best used to communicate data
• Databases are best used to store data