Main Page | Report this Page
Computers Forum Index  »  Computer - Databases - MS SQL Server  »  relationship with const values...
Page 1 of 1    

relationship with const values...

Author Message
ArekK...
Posted: Fri Oct 30, 2009 7:32 pm
Guest
Hi



I have 3 tables In DB.



Def (ObjectIdx PK, ObjectN, ObjectType)
Conf1 (CylinderId PK, Name, ...)
Conf2 (EngineId PK, Name, ...)



Is anyone know how to make relationship with rule below.



Def.ObjectN =Conf1.CylinderId and Def.ObjectType =1
Def.ObjectN =Conf2.EngineId and Def.ObjectType =2
 
ArekK...
Posted: Fri Oct 30, 2009 7:36 pm
Guest
Użytkownik "ArekK" <akrawczyk at (no spam) unico.com.pl> napisał w wiadomości
news:hcf13b$549$1 at (no spam) atlantis.news.neostrada.pl...
Quote:
Hi



I have 3 tables In DB.



Def (ObjectIdx PK, ObjectN, ObjectType)
Conf1 (CylinderId PK, Name, ...)
Conf2 (EngineId PK, Name, ...)



Is anyone know how to make relationship with rule below.



Def.ObjectN =Conf1.CylinderId and Def.ObjectType =1
Def.ObjectN =Conf2.EngineId and Def.ObjectType =2





I frogetted... it's MS SQL Server 2000
 
Plamen Ratchev...
Posted: Fri Oct 30, 2009 7:53 pm
Guest
You can add the object type column (with check constraint) to both Conf1 and Conf2 and then use foreign key constraints
in Conf1 and Conf2. Here is example:
http://consultingblogs.emc.com/davidportas/archive/2007/01/08/Distributed-Keys-and-Disjoint-Subtypes.aspx

--
Plamen Ratchev
http://www.SQLStudio.com
 
ArekK...
Posted: Fri Oct 30, 2009 8:52 pm
Guest
Uzytkownik "Plamen Ratchev" <Plamen at (no spam) SQLStudio.com> napisal w wiadomosci
news:IuidnYPgG6V6lnbXnZ2dnUVZ_rednZ2d at (no spam) speakeasy.net...
Quote:
You can add the object type column (with check constraint) to both Conf1
and Conf2 and then use foreign key constraints in Conf1 and Conf2. Here is
example:
http://consultingblogs.emc.com/davidportas/archive/2007/01/08/Distributed-Keys-and-Disjoint-Subtypes.aspx

--
Plamen Ratchev
http://www.SQLStudio.com

Thanks PR, but this solution i checked before. Sorry, i didn't write this.
In that example you have to add column and fill it the same value.
I'm looking for another idea.
 
Hugo Kornelis...
Posted: Fri Oct 30, 2009 11:22 pm
Guest
On Fri, 30 Oct 2009 17:52:51 +0100, ArekK wrote:

Quote:

Uzytkownik "Plamen Ratchev" <Plamen at (no spam) SQLStudio.com> napisal w wiadomosci
news:IuidnYPgG6V6lnbXnZ2dnUVZ_rednZ2d at (no spam) speakeasy.net...
You can add the object type column (with check constraint) to both Conf1
and Conf2 and then use foreign key constraints in Conf1 and Conf2. Here is
example:
http://consultingblogs.emc.com/davidportas/archive/2007/01/08/Distributed-Keys-and-Disjoint-Subtypes.aspx

--
Plamen Ratchev
http://www.SQLStudio.com

Thanks PR, but this solution i checked before. Sorry, i didn't write this.
In that example you have to add column and fill it the same value.
I'm looking for another idea.


Hi ArekK,

That's the only way using DRI (declare referential integrgity). If you
don't want to do that, then I guess triggers are the only safe option.

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
 
 
Page 1 of 1    
All times are GMT
The time now is Sun Nov 29, 2009 10:29 pm