By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,576 Members | 1,970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,576 IT Pros & Developers. It's quick & easy.

UML and SQL

P: n/a
Hello, could anybody write me how to write an implementation "xor"
association ( used in UML ) in sql ?
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Kind of like this?

select *
from MyTable
where ( col1 = 1 or col2 = 1 ) and not ( col1 = 1 and col2 = 1 )

"Tatiana" <st******@poczta.onet.pl> wrote in message
news:d7**************************@posting.google.c om...
Hello, could anybody write me how to write an implementation "xor"
association ( used in UML ) in sql ?

Jul 23 '05 #2

P: n/a

Unfortunately it is necessary for me during creating table. For example
for one position on bill, which must be described by (IdBill, IdPosBill,
IdServices, IdReserve, Amount). And one position on the bill can concern
either services, or reserve. If one concerns services, so IdReserve must
be NULL and inversely. The problem is how to create such table. Thank
for reply

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3

P: n/a
I am not sure that you can specify that kind of thing in a table constraint.
You may need to create a trigger on the table to disallow that.

"Tatiana Suchodolska" <st******@poczta.onet.pl> wrote in message
news:41**********@127.0.0.1...

Unfortunately it is necessary for me during creating table. For example
for one position on bill, which must be described by (IdBill, IdPosBill,
IdServices, IdReserve, Amount). And one position on the bill can concern
either services, or reserve. If one concerns services, so IdReserve must
be NULL and inversely. The problem is how to create such table. Thank
for reply

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 23 '05 #4

P: n/a
Is this what you mean?

ALTER TABLE Bills ADD CONSTRAINT ck_bills_services_reserve
CHECK ((idservices IS NULL OR idreserve IS NULL)
AND COALESCE(idservices, idreserve) IS NOT NULL)

--
David Portas
SQL Server MVP
--
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.