Title: Association Relationship Transformation of XML Schemas to ObjectRelational Databases
1Association Relationship Transformation of XML
Schemas to ObjectRelational Databases
Bandung, 11 September 2002
- Nathalia Devina Widjaya, David Taniar
- Wenny Rahayu, Eric Pardede
2Structure of Presentation
- Background
- Objectives
- Association Relationship
- Related Work
- Proposed Transformation Methodology
- Conclusion and Future Work
3Background
- The popularity of XML is growing and is gradually
accepted as the standard for describing and
interchanging data between various systems and
databases on the Internet - XML now offers XML Schema definition language as
a substitution of DTD. It provides richer
facilities for defining and constraining the
content of XML documents - With the wide acceptance of the OO conceptual
models, more systems are modeled and expressed
with OO notation. This situation suggests the
necessity to integrate the OO conceptual models
and XML.
4Objectives
- The goal of this work is to present a coherent
way to transform the XML schema into ORDB using
Oracle 9i features models - This transformation is important so that all the
data that are created using XML schema can be
transformed to the database using Oracle format
and features, without eliminating the object
relational features
5Objectives (2)
- The emphasis of this paper is on the
transformation of association relationship to
help people conveniently generate Oracle database - The work presented in this paper is actually part
of a larger research project on Transformation
from XML Schema to Object-Relational Databases. - (i) transformation of aggregation and
inheritance relationship from XML Schema to ORDB - (ii) transformation of association relationship
from XML Schema to ORDB
6Association Relationship
- ORDB was introduced to improve RDB performance
and has become popular because it improves the
limitations of RDB such as lack of support for
new types and composite data values - Since ORDB has OO features, it encapsulates the
static (including association relationship) as
well as dynamic aspects of objects - The association relationship represents a
connection between object instances. Basically,
it is a reference from one object to another that
provides access paths among objects in a system. - The objects are connected through an association
link. The link can have a specified cardinality
one-to-one, one-to-many, many-to-many
7Related Work
- Most existing work has focused on methods to map
RDB to an XML database for database
interoperability. Some works still used DTD and
some have used XML schema. - The previous works include mapping referential
integrity constraints from RDB to XML, semantic
data modeling using XML schemas, hybrid database
schema to map a subset of XML documents onto
database structures, generic-transforming rules
from the OOCM to XML schema, etc. - The transformation of generalization and
aggregation relationship from the XML Schema to
ORDB has been done earlier as a first part of the
project
8Proposed Transformation Methodology
- There are 3 parts of association relationships
that will be transformed, one-to-one association,
one-to-many association and many-to-many
association - The method that we use to implement the
association relationship in Oracle is using
object references (REF). Instead of connecting
two tables through the values of the associated
primary key and foreign key, this method allows
one to directly connecting two tables through
referencing attribute
9One-to-One Relationship
- The example that is used in this section is the
relationship between lecturer and office - For one-to-one association relationship, it is
important to determine the participation of the
objects to decide location of the foreign keys in
relational system
10One-to-One Relationship (2)
- The Transformation steps
- 1. From the XML Schema, element with partial
participation will be recognized by statement
minOccurs 0 maxOccurs 1 . First, create an
object for the one with partial participation
(office) with its attributes
ltcomplexTypegt ltsequencegt ltelement refoffice
minOccurs0 maxOccurs 1 /gt ltelement
reflecture minOccurs0 maxOccursunbounded/
gt lt/sequencegt
11One-to-One Relationship (3)
lt/elementgt ltelement name officegt
ltattribute name officeid type string use
required/gt lt/elementgt
CREATE OR REPLACE TYPE Office_T AS OBJECT
(office_id VARCHAR2(10))
12One-to-One Relationship (4)
2. Create another object for the one with total
participation, lecture, with the attributes and a
REF that refers to office type
ltelement name lecturegt ltattribute name
lectureid type string use required
/gt ltattribute name lectureName type
string use optional /gt
CREATE OR REPLACE TYPE Lecture_T AS OBJECT
(lecture_id VARCHAR2 (10),
lecture_name VARCHAR2 (50),
lecture_office REF office_T)
13One-to-One Relationship (5)
3. Lastly, we create one table for Lecture and
another one for Office. Each table has its id
as well as the constraints
CREATE TABLE Office OF Office_T (office_id NOT
NULL, PRIMARY KEY (office_id)) CREATE TABLE
Lecture OF Lecture_T (lecture_id NOT NULL,
PRIMARY KEY (lecture_id))
14One-to-Many Relationship
- The example that is used in this section is the
relationship between customer and order
15One-to-Many Relationship (2)
- The Transformation steps
- 1. An element with a complex type in XML Schema,
which does not have reference inside it, is
transformed by creating an object in ORDB with
all the attributes
ltxselement name customer type
customerType / gt ltxscomplexType name
customerTypegt lt/xscomplexTypegt
16One-to-Many Relationship (3)
ltxscomplexType name customerTypegt ltxsattribu
te name customerName typexsstring/gt ltxsat
tribute name shippingAddress
typexsstring/gt ltxsattribute name
shippingCity typexsstring/gt ltxsattribute
name shippingState typexsstring/gt ltxsattr
ibute name shippingPostalCode
typexsinteger/gt lt/xscomplexTypegt
CREATE OR REPLACE TYPE Customer_T AS OBJECT
(customer_id VARCHAR2 (10),
customer_name VARCHAR2 (50),
shipping_address VARCHAR2 (100),
shipping_city VARCHAR2 (20),
shipping_state VARCHAR2 (20),
shipping_postalcode NUMBER)
17One-to-Many Relationship (4)
2. For another element in the complex type that
has reference to another element, create another
object and write all the attributes. The
minOccurs 1 and maxOccurs unbounded in
XML will be shown by using REF in Oracle
ltxssequencegt ltxselement name order type
orderType minOccurs 1 max Occurs
unbounded / gt ltxscomplexType name
orderTypegt
18One-to-Many Relationship (5)
ltxscomplexType name orderTypegt ltxsattribut
e name orderID typexsinteger/gt ltxsattribut
e name orderDate type xsdate/gt lt/xscomple
xTypegt
CREATE OR REPLACE TYPE Order_T AS OBJECT
(order_id VARCHAR2(10), order_date DATE,
order_customer REF Customer_T)
19One-to-Many Relationship (6)
3. Lastly, create a table for each type. Each
table has its id as well as the constraints
CREATE TABLE Customer OF Customer_T
(customer_id NOT NULL, PRIMARY KEY
(customer_id)) CREATE TABLE Order OF Order_T
(order_id NOTNULL, PRIMARY KEY (order_id))
20Many-to-Many Relationship
- The example that is used is the relationship
between student and course
21Many-to-Many Relationship (2)
- The Transformation steps
- 1. All elements name that has minOccurs 1 max
Occurs unbounded need to be created as object
in ORDB and write all its attributes
ltxscomplexTypegt ltxssequencegt ltxselement
name students minOccurs 1 maxOccurs
unboundedgt ltxscomplexTypegt ltxselement
name course minOccurs 1 maxOccurs
unboundedgt ltxscomplexTypegt
22Many-to-Many Relationship (3)
ltxselement name studentgt ltxsattribute name
refCourseID type xsstring
/gt ltxsattribute name studentid type
xsstring /gt ltxselement name
coursegt ltxsattribute name refstudentID
type xsstring /gt ltxsattribute name
courseid type xsstring /gt
CREATE OR REPLACE TYPE Student_T AS Object
(student_id VARCHAR2 (10),
student_name VARCHAR2(30)) CREATE OR REPLACE
TYPE Course_T AS Object (course_id VARCHAR2(10
), course_name VARCHAR2(30))
23Many-to-Many Relationship (4)
2. In the XML Schema, each element will be linked
to another element by using the attribute name
that refers to another element ID. For those
elements create table for each of them in ORDB
and add the constraints for the attributes
ltxsattribute name refCourseID type
xsstring /gt ltxsattribute name
refstudentID type xsstring /gt
CREATE TABLE Student OF Student_T
(student_id NOT NULL, PRIMARY
KEY(student_id)) CREATE TABLE Course OF
Course_T (course_id NOT NULL, PRIMARY KEY
(order_id))
24Many-to-Many Relationship (5)
3. Create another table to keep the relationship
between the two connected tables in ORDB. This
table will have reference to the participating
objects
CREATE TABLE Enrolls_in (student REF
Student_T, course REF Course_T)
25Conclusion and Future Work
- In this paper, we have investigated the
transformation from XML schema to the ORDB by
using Oracle 9i, emphasis the transformation of
association relationship - This transformation is important because people
tends to eliminate the object-oriented conceptual
features when they transform XML schema to the
database. - Our future work is being planned to investigate
more transformation from XML schema to ORDB for
other XML Schema features that has not been
discussed in this paper. Further research should
be done to create a query from XML schema to get
the data from the Oracle 9i databases