dbTalk Databases Forums  

unique constraint on two tables?

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss unique constraint on two tables? in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Igor
 
Posts: n/a

Default unique constraint on two tables? - 05-05-2007 , 12:49 PM






Is it possible to create a unique constraint on two tables?
In mssql2000?


Reply With Quote
  #2  
Old   
MC
 
Posts: n/a

Default Re: unique constraint on two tables? - 05-05-2007 , 01:48 PM






You mean spaning two tables? No, not as such. You could try creating an
indexed view, but that will hurt performance. Anyway, perhaps supertype is
in order (depending on the enitites)?

MC


"Igor" <jerosimic (AT) gmail (DOT) com> wrote

Quote:
Is it possible to create a unique constraint on two tables?
In mssql2000?




Reply With Quote
  #3  
Old   
DA Morgan
 
Posts: n/a

Default Re: unique constraint on two tables? - 05-05-2007 , 03:12 PM



Igor wrote:
Quote:
Is it possible to create a unique constraint on two tables?
In mssql2000?
What is the business requirement. What is it you are trying to
accomplish?
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace x with u to respond)


Reply With Quote
  #4  
Old   
Dan Guzman
 
Posts: n/a

Default Re: unique constraint on two tables? - 05-05-2007 , 04:00 PM



I believe UNION is one of the disallowed constructs of an indexed view.
However, I agree that the need to do this is probably a schema design issue.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"MC" <marko.NOSPAMculo (AT) gmail (DOT) com> wrote

Quote:
You mean spaning two tables? No, not as such. You could try creating an
indexed view, but that will hurt performance. Anyway, perhaps supertype is
in order (depending on the enitites)?

MC


"Igor" <jerosimic (AT) gmail (DOT) com> wrote in message
news:1178387342.966780.319330 (AT) q75g2000hsh (DOT) googlegroups.com...
Is it possible to create a unique constraint on two tables?
In mssql2000?





Reply With Quote
  #5  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: unique constraint on two tables? - 05-05-2007 , 04:55 PM



Igor (jerosimic (AT) gmail (DOT) com) writes:
Quote:
Is it possible to create a unique constraint on two tables?
In mssql2000?
Assuming that the two tables have each half of the domain, define
check constraints to keep the tables apart. This in fact how you
implement a partitioned view.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
  #6  
Old   
MC
 
Posts: n/a

Default Re: unique constraint on two tables? - 05-06-2007 , 01:15 AM



You're right offcourse. Union is not allowed in indexed view. So, either
redesign or programmatical checking...


MC


"Dan Guzman" <guzmanda (AT) nospam-online (DOT) sbcglobal.net> wrote

Quote:
I believe UNION is one of the disallowed constructs of an indexed view.
However, I agree that the need to do this is probably a schema design
issue.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"MC" <marko.NOSPAMculo (AT) gmail (DOT) com> wrote in message
news:f1ijhg$c13$1 (AT) ss408 (DOT) t-com.hr...
You mean spaning two tables? No, not as such. You could try creating an
indexed view, but that will hurt performance. Anyway, perhaps supertype
is in order (depending on the enitites)?

MC


"Igor" <jerosimic (AT) gmail (DOT) com> wrote in message
news:1178387342.966780.319330 (AT) q75g2000hsh (DOT) googlegroups.com...
Is it possible to create a unique constraint on two tables?
In mssql2000?







Reply With Quote
  #7  
Old   
Igor
 
Posts: n/a

Default Re: unique constraint on two tables? - 05-07-2007 , 08:53 AM



I redesigned my website so i dont need it now, thank you all.

I had two tables one for opened requests and another for closed
requests, they have different columns. When request is solved it is
moved to requests_finished table and deleted from requests_opened... I
thought i would explain what i wanted but english is not my primary
language and explaining it is so hard and it's not important anymore
so i give up


Reply With Quote
  #8  
Old   
MC
 
Posts: n/a

Default Re: unique constraint on two tables? - 05-08-2007 , 12:57 AM



Well, next time perhaps making one table with requests and adding status
column (opened, closed....)?

MC

PS. Hmm, ili ako si slucajno iz ovih krajeva mozes se ti i na mejl javit


"Igor" <jerosimic (AT) gmail (DOT) com> wrote

Quote:
I redesigned my website so i dont need it now, thank you all.

I had two tables one for opened requests and another for closed
requests, they have different columns. When request is solved it is
moved to requests_finished table and deleted from requests_opened... I
thought i would explain what i wanted but english is not my primary
language and explaining it is so hard and it's not important anymore
so i give up




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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.