From: Eric W. <eri...@gm...> - 2007-10-25 14:01:28
|
Is there any way to specify a uniqueness constraint? |
From: Dannes W. <di...@gm...> - 2007-10-25 14:50:31
|
Eric On 10/25/07, Eric Wittmann <eri...@gm...> wrote: > Is there any way to specify a uniqueness constraint? in what respect is this an eXist specific question? Please make your question a bit longer :-) -- # Dannes Wessels # The Netherlands # |
From: Eric W. <eri...@gm...> - 2007-10-25 18:24:05
|
No problem. Let's say I want to insert the following document into eXist: <Alarm> <ProcessId>7</ProcessId> <ActivityId>17</ActivityId> <Deadline>2008-12-10T12:30:00Z</Deadline> </Alarm> I can insert that content and everything is fine. If I then try to insert another instance of <Alarm> that has the same ProcessId and ActivityId, I would like eXist to fail on the insert. In other words, I want to configure a unique constraint for the given two xpaths: /Alarm/ProcessId /Alarm/ActivityId Much like you would have in SQL for a unique key or primary key. Another example is Tamino - which allows for the creation of xpath-defined unique constraints in a doctype. In the normal course of operation, our software will not try to insert two documents that are the same. However, recently we found a defect during our application crash recovery code, where we had a bug that caused a duplicate Alarm document to be inserted. When running against SQL, this bug was obvious (because it failed fast with a UNIQUE KEY CONSTRAINT VIOLATION sql error). When running against eXist, there was obviously no error. So I'm wondering if eXist already has a feature like this, or will I need to add a custom layer within or on top of eXist. Thanks, - Eric Dannes Wessels wrote: > Eric > > On 10/25/07, Eric Wittmann <eri...@gm...> wrote: >> Is there any way to specify a uniqueness constraint? > > in what respect is this an eXist specific question? Please make your > question a bit longer :-) > |
From: Pierrick B. <pie...@fr...> - 2007-10-25 19:11:32
|
Hi, Eric Wittmann a écrit : > Much like you would have in SQL for a unique key or primary key. > Another example is Tamino - which allows for the creation of > xpath-defined unique constraints in a doctype. By definition, this is an aplication constraint. I would consider eXist's triggers to do that, or a highler-level application design. > In the normal course of operation, our software will not try to > insert two documents that are the same. However, recently we found a > defect during our application crash recovery code, where we had a bug > that caused a duplicate Alarm document to be inserted. When running > against SQL, this bug was obvious (because it failed fast with a > UNIQUE KEY CONSTRAINT VIOLATION sql error). When running against > eXist, there was obviously no error. Sure. eXist makes no assumption about what you want to insert/upload in you DB. Just like in a file system.... > So I'm wondering if eXist already has a feature like this, or will I > need to add a custom layer within or on top of eXist. See above. You somehow need to add a "custom" layer. Well, we might consider "default" (XQuery) triggers to provide an easy (and more powerful) way to enforce such constraints... Cheers, p.b. |
From: Adam R. <ada...@de...> - 2007-10-26 09:24:55
|
Two possible existing ways of achieving this are through either - 1) Validation - create a XML Schema for the document and switch on = validation so that the document will fail to upload/insert if it does = not match the Schema. 2) Triggers, create a custom trigger in XQuery or Java that throws an = exception at prepare time if the document is judged to be invalid - = extending DocumentFilter should do the trick using the SAX methods would = be my recommendation. -----Original Message----- From: exi...@li... on behalf of Eric = Wittmann Sent: Thu 25/10/2007 19:23 To: eXist Subject: Re: [Exist-open] Unique constraints. =20 No problem. Let's say I want to insert the following document into eXist: <Alarm> <ProcessId>7</ProcessId> <ActivityId>17</ActivityId> <Deadline>2008-12-10T12:30:00Z</Deadline> </Alarm> I can insert that content and everything is fine. If I then try to=20 insert another instance of <Alarm> that has the same ProcessId and=20 ActivityId, I would like eXist to fail on the insert. In other words, I want to configure a unique constraint for the given=20 two xpaths: /Alarm/ProcessId /Alarm/ActivityId Much like you would have in SQL for a unique key or primary key.=20 Another example is Tamino - which allows for the creation of=20 xpath-defined unique constraints in a doctype. In the normal course of operation, our software will not try to insert=20 two documents that are the same. However, recently we found a defect=20 during our application crash recovery code, where we had a bug that=20 caused a duplicate Alarm document to be inserted. When running against=20 SQL, this bug was obvious (because it failed fast with a UNIQUE KEY=20 CONSTRAINT VIOLATION sql error). When running against eXist, there was=20 obviously no error. So I'm wondering if eXist already has a feature like this, or will I=20 need to add a custom layer within or on top of eXist. Thanks, - Eric Dannes Wessels wrote: > Eric >=20 > On 10/25/07, Eric Wittmann <eri...@gm...> wrote: >> Is there any way to specify a uniqueness constraint? >=20 > in what respect is this an eXist specific question? Please make your > question a bit longer :-) >=20 -------------------------------------------------------------------------= This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Exist-open mailing list Exi...@li... https://lists.sourceforge.net/lists/listinfo/exist-open |
From: lorenzo c. <lor...@me...> - 2007-11-20 15:13:28
|
Adam Retter <adam.retter <at> devon.gov.uk> writes: > > > > Two possible existing ways of achieving this are through either - > 1) Validation - create a XML Schema for the document and switch on validation so that the document will fail to upload/insert if it does not match the Schema. > 2) Triggers, create a custom trigger in XQuery or Java that throws an exception at prepare time if the document is judged to be invalid - extending DocumentFilter should do the trick using the SAX methods would be my recommendation. Hi, I'm facing the same issue described in this thread. Thanks Adam for the advices. If I'm not wrong, I think that only the second solution you proposed can work here, since the xs:unique constraint (or xs:key) in an XML Schema works only within the document scope. Can anyone confirm that? Thanks, lorenzo |