Composite Primary Keys in XSD

J

Jan Bannister

I'm using an XSD DataSet and i've put all the
DataRelations into it. A nunber of my table use composite
(in particular, 2 column keys). This is reflected by the
following Constraint in the xsd:

<xs:unique name="Installation_Constraint1"
msdata:ConstraintName="PrimaryKey"
msdata:primaryKey="true">
<xs:selector xpath=".//mstns:Installation" />
<xs:field xpath="mstns:Company" />
<xs:field xpath="mstns:Name" />
</xs:unique>

Which has the side effect of requiring both feilds to be
Unique. This is not the case, which is why they are a
composite key.
I can drop the constraint but that damages the data model
and ignoring the error with exceptions is ineffcient as
this will likly mean 10-20 exceptions a second in
standard operation.
Does anyone know an alternate constraint syntax? Or
another (cleaner) way for dealing with this kind of issue?

Thanks in advance
Jan
 
M

Miha Markic

Hi Jan,

Try this:
<xs:key name="Installation_Constraint1" msdata:primaryKey="true">

<xs:selector xpath=".//mstns:Installation" />

<xs:field xpath="mstns:Company" />

<xs:field xpath="mstns:Name" />

</xs:key>
 
J

Jan Bannister

Thanks *again* Miha,

You seem to be the one greasin' the wheels. That worked
perfectly. I can't believe I was looking at an
<xs:unique> tag and wondering why it wasnt behaving like
an key.
I'm still relativly new to the whole XSD thing but its
really cool. Modelling your data before you plough into
gui work is a really comforting feeling and XSD really
helps.

Many Thanks
Jan
 
M

Miha Markic

Hi Jan,

Jan Bannister said:
Thanks *again* Miha,

You seem to be the one greasin' the wheels. That worked
perfectly. I can't believe I was looking at an
<xs:unique> tag and wondering why it wasnt behaving like
an key.

Great :)
I'm still relativly new to the whole XSD thing but its
really cool. Modelling your data before you plough into
gui work is a really comforting feeling and XSD really
helps.

Yup, very usefull.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top