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

RE: Constraint Specifications in XML Schemas

From: Dare Obasanjo <dareo@microsoft.com>
Date: Fri, 25 Oct 2002 16:13:30 -0700
Message-ID: <B885BEDCB3664E4AB1C72F1D85CB29F8040EF6DA@RED-MSG-10.redmond.corp.microsoft.com>
To: "Alexandre Martins" <alex.martins@netc.pt>, <xmlschema-dev@w3.org>

The schema you are trying to describe does not seem beyond the abilities of xs:key and xs:keyref. However it is definitely beyond the abilities of RELAX NG since I believe key/keyref was removed from the language. 

	-----Original Message----- 
	From: Alexandre Martins [mailto:alex.martins@netc.pt] 
	Sent: Fri 10/25/2002 2:52 PM 
	To: xmlschema-dev@w3.org 
	Cc: 
	Subject: Constraint Specifications in XML Schemas
	
	



	Hi!
	
	I've been trying to write a XML vocabulary to describe a relational database
	schema, for example:
	
	<DataBase id="teste" url="jdbc:mysql://localhost/teste" user="xano"
	passwd="xpto" driver="com.mysql.jdbc.Driver"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:noNamespaceSchemaLocation="bd-v2.xsd">
	
	  <Table id="Film">
	    <Field id="idFilm" type="INTEGER">Film Number</Field>
	    <Field id="title" type="VARCHAR" size="40">Title</Field>
	    <Field id="year" type="INTEGER">Year</Field>
	    <PrimaryKey>
	      <KeyField fieldId="idFilm"/>
	    </PrimaryKey>
	  </Table>
	  <Table id="Actor">
	    <Field id="idActor" type="INTEGER">Actor Number</Field>
	    <Field id="name" type="VARCHAR" size="25">Name</Field>
	    <Field id="birthDate" type="DATE">Birthdate</Field>
	    <PrimaryKey>
	      <KeyField fieldId="idActor"/>
	    </PrimaryKey>
	  </Table>
	  <Table id="FilmActor">
	    <Field id="idFilm" type="INTEGER">Film Number</Field>
	    <Field id="idActor" type="INTEGER">Actor Number</Field>
	    <Field id="character" type="VARCHAR" size="20">Character</Field>
	    <PrimaryKey>
	      <KeyField fieldId="idFilm"/>
	      <KeyField fieldId="idActor"/>
	    </PrimaryKey>
	    <ForeignKey>
	      <FieldRef fieldId="idFilm"/>
	      <ForeignTable tableId="Film">
	        <ForeignField fieldId="idFilm"/>
	      </ForeignTable>
	    </ForeignKey>
	    <ForeignKey>
	      <FieldRef fieldId="idActor"/>
	      <ForeignTable tableId="Actor">
	        <ForeignField fieldId="idActor"/>
	      </ForeignTable>
	    </ForeignKey>
	  </Table>
	</DataBase>
	
	In order to validate certain constraints related with the relational model
	rules, I've been developing a XML Schema.
	But I've not been able to write a XML Schema constraint to guarantee
	that a ForeignKey element content must be a PrimaryKey on the other table
	(i've trying with key and keyref).
	Is it possible to write this using XML Schema or must I use Relax NG??
	
	Thanks,
	Alexandre Martins
	
	
	
	
	_______________________________________________________
	Vizzavi Mail powered by Vodafone - http://www.vizzavi.pt
	Virus protected by TrendMicro - http://www.antivirus.com
	
	
Received on Friday, 25 October 2002 19:14:12 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:34 GMT