PC Review


Reply
Thread Tools Rate Thread

Composite Primary Keys in XSD

 
 
Jan Bannister
Guest
Posts: n/a
 
      16th Dec 2003
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




 
Reply With Quote
 
 
 
 
Miha Markic
Guest
Posts: n/a
 
      16th Dec 2003
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>


--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"Jan Bannister" <(E-Mail Removed)> wrote in message
news:0b3d01c3c3c8$e3bfa8d0$(E-Mail Removed)...
> 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
>
>
>
>



 
Reply With Quote
 
Jan Bannister
Guest
Posts: n/a
 
      16th Dec 2003
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



>-----Original Message-----
>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>
>
>
>--
>Miha Markic - RightHand .NET consulting & software

development
>miha at rthand com
>
>"Jan Bannister" <(E-Mail Removed)> wrote in message
>news:0b3d01c3c3c8$e3bfa8d0$(E-Mail Removed)...
>> 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
>>
>>
>>
>>

>
>
>.
>

 
Reply With Quote
 
Miha Markic
Guest
Posts: n/a
 
      16th Dec 2003
Hi Jan,

"Jan Bannister" <(E-Mail Removed)> wrote in message
news:0b1301c3c3d9$b07282c0$(E-Mail Removed)...
> 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.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Composite Key vs Primary Secondary Keys Elaine Microsoft Access Database Table Design 6 9th Apr 2008 02:46 AM
Composite-key Primary Keys ==>> Foreign Keys Michael Microsoft Access Database Table Design 5 7th Nov 2007 11:47 AM
Lookups with Composite primary keys - How To? mac Microsoft Access Database Table Design 6 15th Sep 2006 06:07 PM
Lookups with Composite primary keys - How To? mac Microsoft Access 6 15th Sep 2006 06:07 PM
Lookups with Composite primary keys - How To? mac Microsoft Access Queries 1 15th Sep 2006 03:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:28 PM.