Composite Primary Keys in XSD

  • Thread starter Thread starter Jan Bannister
  • Start date Start date
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
 
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>
 
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
 
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.
 
Back
Top