unique constraint on two tables?

unique constraint on two tables?

am 05.05.2007 19:49:03 von igor

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

Re: unique constraint on two tables?

am 05.05.2007 20:48:15 von MC

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" wrote in message
news:1178387342.966780.319330@q75g2000hsh.googlegroups.com.. .
> Is it possible to create a unique constraint on two tables?
> In mssql2000?
>

Re: unique constraint on two tables?

am 05.05.2007 22:12:39 von DA Morgan

Igor wrote:
> 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)

Re: unique constraint on two tables?

am 05.05.2007 23:00:01 von Dan Guzman

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" wrote in message
news:f1ijhg$c13$1@ss408.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" wrote in message
> news:1178387342.966780.319330@q75g2000hsh.googlegroups.com.. .
>> Is it possible to create a unique constraint on two tables?
>> In mssql2000?
>>
>
>

Re: unique constraint on two tables?

am 05.05.2007 23:55:13 von Erland Sommarskog

Igor (jerosimic@gmail.com) writes:
> 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@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downlo ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books .mspx

Re: unique constraint on two tables?

am 06.05.2007 08:15:56 von MC

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


MC


"Dan Guzman" wrote in message
news:lf6%h.222$4X.95@nlpi069.nbdc.sbc.com...
>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" wrote in message
> news:f1ijhg$c13$1@ss408.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" wrote in message
>> news:1178387342.966780.319330@q75g2000hsh.googlegroups.com.. .
>>> Is it possible to create a unique constraint on two tables?
>>> In mssql2000?
>>>
>>
>>
>

Re: unique constraint on two tables?

am 07.05.2007 15:53:03 von igor

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

Re: unique constraint on two tables?

am 08.05.2007 07:57:26 von MC

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" wrote in message
news:1178545983.249305.210700@e65g2000hsc.googlegroups.com.. .
>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 :)
>