Copyright 2002, Ronald Bourret, XML-DBMS Middleware for XML and databases Ronald Bourret O'Reilly Open.

Slides:



Advertisements
Similar presentations
XML: Extensible Markup Language
Advertisements

Michael Pizzo Software Architect Data Programmability Microsoft Corporation.
XML Unit 6 October 31. XML, review XML is used to markup data Used to describe information Uses tags like HTML –But all tags are user-defined –Must be.
Introduction to Database Processing with ADO.NET.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
IS432: Semi-Structured Data Dr. Azeddine Chikh. 8. XML Relational Mapping.
ASP.NET Programming with C# and SQL Server First Edition
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 David M. Kroenke Database Processing Chapter 7 Structured Query Language.
SQL Overview Defining a Schema CPSC 315 – Programming Studio Spring 2008 Project 1, Lecture 3 Slides adapted from those used by Jeffrey Ullman, via Jennifer.
DB Audit Expert v1.1 for Oracle Copyright © SoftTree Technologies, Inc. This presentation is for DB Audit Expert for Oracle version 1.1 which.
XMLII XSchema XSchema XQuery XQuery. XML Schema XML Schema is a more sophisticated schema language which addresses the drawbacks of DTDs. Supports XML.
XML, distributed databases, and OLAP/warehousing The semantic web and a lot more.
SQL Overview Defining a Schema CPSC 315 – Programming Studio Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch Via Yoonsuck Choe.
Structured Query Language (SQL) A2 Teacher Up skilling LECTURE 2.
CSCI 6962: Server-side Design and Programming
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
XML-to-Relational Schema Mapping Algorithm ODTDMap Speaker: Artem Chebotko* Wayne State University Joint work with Mustafa Atay,
Databases and LINQ Visual Basic 2010 How to Program 1.
ASP.NET Programming with C# and SQL Server First Edition
XML and JAVA Joon C. Ho. Why is XML ? 7654 MARTIN SALESMAN SCOTT ANALYST 3000 HTMLCorresponding XML 7654 MARTIN SALESMAN
DATABASE and XML Moussa Mané. Learning Objectives ● Learn about Native XML Databases ● Learn about the conversion technology available ● Understand New.
Data Access Patterns Some of the problems with data access from OO programs: 1.Data source and OO program use different data modelling concepts 2.Decoupling.
1 Overview of Databases. 2 Content Databases Example: Access Structure Query language (SQL)
Introduction to SQL Steve Perry
XML Structures For Existing Databases Ref: 106.ibm.com/developerworks/xml/library/x-struct/
Copyright  Oracle Corporation, All rights reserved. 4 CMIS Powell Oracle Designer: Creating the Database Design CMIS Powell.
Needs for Accessing Database To make your web site more dynamic and maintainable, you can display information on your web pages that are retrieved from.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
 2004 Prentice Hall, Inc. All rights reserved. 1 Segment – 6 Web Server & database.
WEB BASED DATA TRANSFORMATION USING XML, JAVA Group members: Darius Balarashti & Matt Smith.
5/24/01 Leveraging SQL Server 2000 in ColdFusion Applications December 9, 2003 Chris Lomvardias SRA International
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
SCUHolliday - coen 1788–1 Schedule Today u Modifications, Schemas, Views. u Read Sections (except and 6.6.6) Next u Constraints. u Read.
Visual Programing SQL Overview Section 1.
XML and Database.
Copyright 2000, 2001, Ronald Bourret, Mapping DTDs to Databases Ronald Bourret
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
Computing & Information Sciences Kansas State University Friday, 20 Oct 2006CIS 560: Database System Concepts Lecture 24 of 42 Friday, 20 October 2006.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
Chapter 14 1 Chapter 14 Storing and Retrieving XML in SQL Server 2000 November 6, 2001 Sook-Kyo Kwon.
Session 1 Module 1: Introduction to Data Integrity
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
Database Connectivity with ASP.NET. 2 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting.
Module 3: Using XML. Overview Retrieving XML by Using FOR XML Shredding XML by Using OPENXML Introducing XQuery Using the xml Data Type.
Experience with XML Schema Ashok Malhotra Schema Usage  Mapping XML Schema and XML documents controlled by the Schema to object classes and instances.
D Copyright © 2004, Oracle. All rights reserved. Using Oracle XML Developer’s Kit.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
uses of DB systems DB environment DB structure Codd’s rules current common RDBMs implementations.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
Introduction to Database Programming with Python Gary Stewart
I Copyright © 2004, Oracle. All rights reserved. Introduction.
XP Chapter 1 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Level 2 Objectives: Understanding and Creating Table.
Data Resource Management Data Concepts Database Management Types of Databases Chapter 5 McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies,
IS432 Semi-Structured Data
Introduction to Database Processing with ADO.NET
Introduction to Database Processing with ADO.NET
Visual Basic 2010 How to Program
This is the cover slide..
Chapter 5 Introduction to SQL.
CS320 Web and Internet Programming SQL and MySQL
Server-Side Application and Data Management IT IS 3105 (FALL 2009)
SQL OVERVIEW DEFINING A SCHEMA
CS3220 Web and Internet Programming SQL and MySQL
CS3220 Web and Internet Programming SQL and MySQL
CMSC-461 Database Management Systems
Presentation transcript:

Copyright 2002, Ronald Bourret, XML-DBMS Middleware for XML and databases Ronald Bourret O'Reilly Open Source Convention, Marina II

Copyright 2002, Ronald Bourret, Overview Introduction Object-relational mapping Mapping language Using XML-DBMS

Copyright 2002, Ronald Bourret, Introduction

Copyright 2002, Ronald Bourret, XML-DBMS Transfers data between XML documents and RDBMSs »Has capabilities similar to HiT Allora, DB/XML Transform, SQL Server, DB2, Oracle 8i Based on an object-relational mapping Best for data-centric documents »Can handle document-centric documents Open Source / public domain Available in Java (1.x, 2.0) and PERL (1.x)

Copyright 2002, Ronald Bourret, Features (version 2.0) Command line and programmatic interfaces XML-based mapping language »Automatic map generation from DTDs and database schemas Inserts, updates, deletes, and selects Heterogenous joins Customizable string formatting and key generation Parser and database independent

Copyright 2002, Ronald Bourret, Object-Relational Mapping

Copyright 2002, Ronald Bourret, A simple example There is an obvious mapping from this document... bbb ccc ddd

Copyright 2002, Ronald Bourret, A simple example (cont.)... to this object... bbb ccc ddd object A { B = "bbb" C = "ccc" D = "ddd" }

Copyright 2002, Ronald Bourret, A simple example (cont.)... to a row in this table bbb ccc ddd object A { B = "bbb" C = "ccc" D = "ddd" } Table A B C D bbb ccc ddd

Copyright 2002, Ronald Bourret, A more complex example Gallagher Industries A B This XML document...

Copyright 2002, Ronald Bourret, A more complex example (cont.) object Order { number = 1234; customer = "Gallagher Industries"; date = ; items = {ptrs to Item objects}; } object Item { number = 1; part = "A-10"; quantity = 12; price = 10.95; } object Item { number = 2; part = "B-43"; quantity = 600; price = 3.99; }... maps to these objects...

Copyright 2002, Ronald Bourret, Orders Number Customer Date 1234 Gallagher Industries Items SONumber Item Part Quantity Price A B A more complex example (cont.)... which map to these rows

Copyright 2002, Ronald Bourret, Mapping performed at schema level Mapping requires “effective” XML schema / DTD Actual XML schema / DTD not required class A { String B; String C; String D; } CREATE TABLE A ( B VARCHAR(10) NOT NULL, C VARCHAR(10) NOT NULL, D VARCHAR(10) NOT NULL )

Copyright 2002, Ronald Bourret, Objects are data-specific... Different for each DTD (schema) Model the content (data) of the document Order Customer Item Part

Copyright 2002, Ronald Bourret, not the DOM Same for all XML documents Model the structure of the document Element Attr (Order) (OrderNumber) Element Element Element (Customer) (OrderDate) (Item)

Copyright 2002, Ronald Bourret, Objects not instantiated Data transferred directly between XML and database Objects used only to visualize the mapping XML data binding products instantiate objects »Castor »JAXB »Zeus »...

Copyright 2002, Ronald Bourret, The basic mapping

Copyright 2002, Ronald Bourret, Element types are data types “Simple” element types have PCDATA-only content “Complex” element types have element or mixed content and/or attributes <!ATTLIST Customer CustNum CDATA #REQUIRED Name CDATA #REQUIRED Address CDATA #REQUIRED>

Copyright 2002, Ronald Bourret, Mapping “complex” element types Map complex element types to classes which are mapped to tables (class tables) class A {... } class A {... } Table A...

Copyright 2002, Ronald Bourret, Mapping content models Map references to simple element types to scalar properties which are mapped to data columns class A { String b;... } class A { String b;... } Table A Column b...

Copyright 2002, Ronald Bourret, Mapping content models (cont.) Map references to “complex” element types to pointer/reference properties which are mapped to primary / foreign key columns class A { String b; C c;... } Table A Column b Column a_pk... Table C Column a_fk... class C {... } class A { String b; C c;... } class C {... }

Copyright 2002, Ronald Bourret, Mapping attributes Map attributes to scalar properties which are mapped to data columns class A { String b; C c; String f; } class A { String b; C c; String f; } Table A Column b Column a_pk Column f Table C Column a_fk...

Copyright 2002, Ronald Bourret, The basic mapping: reprise Map “complex” element types to classes, then to tables Map content models to properties, then to columns Map attributes to properties, then to columns Join class tables with primary key / foreign key pairs

Copyright 2002, Ronald Bourret, Some important points

Copyright 2002, Ronald Bourret, Map each reference separately Map references separately for each content model True for references to simple types and complex types class Chapter { String title; Section[] sections; } class Appendix { String title; Section[] sections; }

Copyright 2002, Ronald Bourret, Mapping can change data types Can map “simple” data types to any scalar data type class Part { String number; float price; } CREATE TABLE Part ( number CHAR(10) NOT NULL, price REAL NOT NULL }

Copyright 2002, Ronald Bourret, Mapping can change names XML schema, object schema, and relational schema can use different names class PartClass { String numberProp; float priceProp; } CREATE TABLE PRT ( PRTNUM CHAR(10) NOT NULL, PRTPRICE REAL NOT NULL )

Copyright 2002, Ronald Bourret, Primary and foreign keys Primary key on “one” side of one-to-many relationship May be in table of parent or child ABC Table Orders Number, Date Table Parts Number, Price Table Items SONum, Num, Part, Qty

Copyright 2002, Ronald Bourret, Handling order Object and relational schemas have no concept of order Store order in mapping (has limitations) or in separate property / column (no limitations) class A { String b; int bOrder; C c; int cOrder } Mapping for A: B at position 1 C at position 2

Copyright 2002, Ronald Bourret, No transformations XML and database schemas must have same structure »Use XSLT when they don’t XML XML Database Database XML XML XSLT Map Map XSLT XML query languages can perform transformations

Copyright 2002, Ronald Bourret, Mapping Language

Copyright 2002, Ronald Bourret, Mapping language Maps XML schema to relational schema »Declares relational schemaa »Declares object view of XML document »Maps object view to relational schema Many options »Key generation »Character formatting »etc.

Copyright 2002, Ronald Bourret, Declaring database schema Orders Number CustNumber Date

Copyright 2002, Ronald Bourret, Mapping complex element types (classes) to tables... property, related class, and inline class maps... Orders Number CustNumber Date...

Copyright 2002, Ronald Bourret, Mapping simple element types (properties) to columns Orders Number CustNumber Date

Copyright 2002, Ronald Bourret, Mapping attributes (properties) to columns Orders Number CustNumber Date...

Copyright 2002, Ronald Bourret, Mapping parent/child (inter-class) relationships to keys Orders Number CustNumber Date Items SONumber Number Product Qty

Copyright 2002, Ronald Bourret, “Inlining” complex element types... property, related class, and inline class maps... Customers Number Name Street City... Gallagher, Inc. 123 Main St. Chicago...

Copyright 2002, Ronald Bourret, Additional mapping features Distribute document across multiple databases Single- and multi-column keys Generate keys in database or custom class Store order in map or database Custom character formatting Support for mixed content Support for namespaces...

Copyright 2002, Ronald Bourret, Using XML-DBMS

Copyright 2002, Ronald Bourret, Using XML-DBMS 1.Write or generate a map file 2.Write an action document (insert, update, delete) 3. Write a filter document (select, delete) 4. Call XML-DBMS from: »Command line »Your application (high- or low-level API)

Copyright 2002, Ronald Bourret, Generating map files Can generate from DTD or database schema Usually need to customize by hand »Fix names »Optimize mapping (identify keys, inline classes, etc.) »Add formatting »... Can generate CREATE TABLE statements or DTD

Copyright 2002, Ronald Bourret, Action documents Used by insert, update, and delete Specify default action and per-class actions Supported actions: »Insert »Soft insert »Update »Update-or-insert »Delete »Soft delete »None

Copyright 2002, Ronald Bourret, Action documents (cont.)

Copyright 2002, Ronald Bourret, Filter documents Used by select and delete Specify additional WHERE conditions Support named parameters Map + filter = query

Copyright 2002, Ronald Bourret, Filter documents (cont.) 10" />

Copyright 2002, Ronald Bourret, Using the command line Use the Transfer tool Pass a set of property-value pairs c:> java org.xmlmiddleware.xmldbms.tools.Transfer property=value [property=value...]

Copyright 2002, Ronald Bourret, Using the command line (cont.) Specify properties explicitly or store in property files c:> java org.xmlmiddleware.xmldbms.tools.Transfer Driver=sun.jdbc.odbc.JdbcOdbcDriver DataSourceClass=org.xmlmiddleware.db.JDBC1DataSource URL=jdbc:odbc:xmldbms User=ron Password=scrumps ParserUtilsClass= org.xmlmiddleware.xmlutils.external.ParserUtilsXerces Method=StoreDocument MapFile=orders.map ActionFile=orders.act XMLFile=orders.xml c:> java org.xmlmiddleware.xmldbms.tools.Transfer File1=db.props File2=xerces.props File3=storeorder.props

Copyright 2002, Ronald Bourret, Using the high-level API // Create a new Transfer object Properties p = new Properties(); p.load(new FileInputStream("xerces.props")); Transfer t = new Transfer(p); // Initialize the data source p.load(new FileInputStream("db.props")); t.setDatabaseProperties(props); // Store a document t.storeDocument(null, "orders.xml", "orders.map", "orders.act");

Copyright 2002, Ronald Bourret, Using the low-level API // Set up the parser ParserUtils utils = new ParserUtilsXerces(); XMLReader reader = utils.getXMLReader(true); // Create a map object MapCompiler mapCompiler = new MapCompiler(reader); InputSource is = new InputSource(new FileInputStream("orders.map")); XMLDBMSMap map = mapCompiler.compile(is); // Create an action object ActionCompiler actionCompiler = new ActionCompiler(reader); is = new InputSource(new FileInputStream("orders.act")); Actions actions = actionCompiler.compile(map, is);

Copyright 2002, Ronald Bourret, Using the low-level API (cont.) // Create a data source and data handler for our database, then // bundle these into a TransferInfo object. DataSource ds = new JDBC1DataSource("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:xmldbms"); DataHandler dh = new GenericHandler(ds, null, null); TransferInfo ti = new TransferInfo(map, null, handler); // Create a new DOMToDBMS object, open the document, and call // storeDocument to transfer the data. DOMToDBMS domToDBMS = new DOMToDBMS(); is = new InputSource(new FileInputStream("orders.xml")); Document doc = utils.openDocument(is); domToDBMS.storeDocument(ti, doc, actions);

Copyright 2002, Ronald Bourret, Current status Java version 1.01 available from Web site Java version 1.02 ships with JBuilder 5 and later PERL version 1.03 available from Web site »Has filtering capabilities Java version 2.0 alpha available from Web site »Feature complete »Needs code cleanup, bug fixes, documentation 500+ people on mailing list

Copyright 2002, Ronald Bourret, Resources XML-DBMS home page » XML-DBMS Source Forge site » Mapping DTDs to Databases »

Copyright 2002, Ronald Bourret, Questions? Ronald Bourret