W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2000

help! How to represent relationships and inverse attributes in XML Schema?

From: Xin Ye <xinye98@yahoo.com>
Date: Mon, 16 Oct 2000 00:00:32 -0700 (PDT)
Message-ID: <20001016070032.23860.qmail@web217.mail.yahoo.com>
To: xmlschema-dev@w3.org

I am new to this list. Currently I am doing some
studying as well as research in XML Schema area. I am
actually a beginner. 

The question I have is how to represent/implement
inverse attributes in XML Schema. A direct example is
how to represent 1:N relationship in XML Schema? 

In particular my question consists of the following 2,
please see more explanation later in this post.

1. How to represent 1:N relationship in XML Schema in
a simple way without the recursive definition. 

2. How to represent/implement inverse attributes in
XML Schema and how to implement it, if we could. 

In relational model, we could simply use foreign key
to achieve these goals. 

In ODMS, we could use inverse attributes. For example,
Department and students are a 1:N relationship. In
ODMS, we could simply put it in this way:

Class Department
{ ...
  Attribute students set<Students> inverse

Class Student
{ ...
  Attribute majorin Department inverse

The ODMS will try to maintain the referential
integrity and all of this work would be transparent to
the users.

However, how to represent the inverse attributes in
XML Schema. In essential, how to represent 1:N
relationship. Still taking the above example of
and department, how to represent this clearly in XML
Schema? Till now, I could not figure out a easy way to
do it.

You may simply include Department as a sub element in
the Student's complexType definition. And does the
same thing to Department. But that will cause some
recursive definition since department contains
students which contain department again! 

<complexType name="Student">
 <element name="majorindept" type="Department"/>

<complexType name="Department">
 <element name="hasstudent" type="Student" minOccur=1

In the above example, Department has an element of
type Student, but in the definition of type Student it
again has an element of type Department which again
has an element of student ... How to represent a
student or deparment in their INSTANCE documents seems
to me like a big issue, although 1:N relationship has
been clearly represented in the above schema

Furthermore, how to make sure "majorindept" in the
definition of Studnet be the inverse attribute of
"hasstudent" in the definition of Department? 

In ODMS, using inverse attributes to represent 1:N as
well as maintaining the referential integrity could be
easily addressed because we have parent links
implemented in the System which solved this issue.

My intuitive feeling is this(specifying inverse
attributes) is really an implementation issue rather
than finding a way to specify it in XML Schema
complexType definition or in ODMS Class definition. 

So actually, my questions becomes the following 2:

1. How to represent 1:N relationship in XML Schema
without the recursive definition. (We could only
define the in a single direction but with both
direction we could have entry points to the instances
of both Student and Department schema to do operation
like search more efficiently) This is the most
important issue currently I am thinking about.

2. How to represent/implement inverse attributes in
XML Schema to maitain the referential integrity( of
course anwsering question needs too much work but I
only need some intuitive hint), if we could. XML
schema does provide "keyref" for referential integrity
but it looks more similar to relational model's
foreign key not ODMS's inverse attributes which
represent relationships much more easily and clearly.
Hope some of experts here could kindly help me. Give
me some insightful advice and suggestion. Perhaps
somebody already thought of it before.

Thanks a lot!

Xin Ye

Do You Yahoo!?
Yahoo! Messenger - Talk while you surf!  It's FREE.
Received on Monday, 16 October 2000 03:00:33 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:47 UTC