Unix Technical Forum

UML and SQL

This is a discussion on UML and SQL within the SQL Server forums, part of the Microsoft SQL Server category; --> Hello, could anybody write me how to write an implementation "xor" association ( used in UML ) in sql ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 05:15 AM
Tatiana
 
Posts: n/a
Default UML and SQL

Hello, could anybody write me how to write an implementation "xor"
association ( used in UML ) in sql ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 05:15 AM
David Rawheiser
 
Posts: n/a
Default Re: UML and SQL

Kind of like this?

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

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



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 05:15 AM
Tatiana Suchodolska
 
Posts: n/a
Default Re: UML and SQL


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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 05:15 AM
David Rawheiser
 
Posts: n/a
Default Re: UML and SQL

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" <statiana@poczta.onet.pl> wrote in message
news:41c3b842$1_2@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!



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-29-2008, 05:15 AM
David Portas
 
Posts: n/a
Default Re: UML and SQL

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
--


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:57 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com