Re: Problem with UNIQUE constraint

Hi Gary,

>> By the way, I think that you're probably using the identity constraint
>> incorrectly. If you want to test that each Rec_SelRadioSrvc element
>> has a unique combination of LineID and RadioService, then you need to
>> place the identity constraint on the declaration of the element that's
>> the *parent* of the Rec_SelRadioServc element, as follows:
>> 
>>   <xs:unique name="ID_SelRadioSrvc">
>>     <xs:selector xpath="Rec_SelRadioSrvc"/>
>>     <xs:field xpath="LineID"/>
>>     <xs:field xpath="RadioService"/>
>>   </xs:unique>
>> 
>> As you currently have it, all you're testing is that the LineID and
>> RadioService of one Rec_SelRadioSrvc at a time. There isn't much point
>> doing that unless you're using the identity constraint sneakily to
>> test a co-occurrence constraint, which I don't think is the case here.
>
> Yes, you are quite right.  I need to change the selector xpath to "*".

Well, you can do, but that won't make any difference unless you also
move the xs:unique identity constraint into the element declaration
for the element that contains the elements that you want to test for
uniqueness. If you keep the xs:unique where it is, and just change the
selector xpath, then you'll be testing whether each child element of
the Rec_SelRadioSrvc (i.e. the LineID and RadioService elements) have
a unique combination of LineID and RadioService child elements, which
I doubt is what you're after.

The location where you place the xs:unique determines the scope of the
identity constraint. The xs:selector selects the elements that should
be unique. The xs:field elements identify the fields on which those
elements should be unique.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Thursday, 28 March 2002 03:58:24 UTC