Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

relationship with const values

0 views
Skip to first unread message

ArekK

unread,
Oct 30, 2009, 11:32:40 AM10/30/09
to
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

unread,
Oct 30, 2009, 11:36:43 AM10/30/09
to

U�ytkownik "ArekK" <akra...@unico.com.pl> napisa� w wiadomo�ci
news:hcf13b$549$1...@atlantis.news.neostrada.pl...

I frogetted... it's MS SQL Server 2000


Plamen Ratchev

unread,
Oct 30, 2009, 11:53:12 AM10/30/09
to
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

unread,
Oct 30, 2009, 12:52:51 PM10/30/09
to

Uzytkownik "Plamen Ratchev" <Pla...@SQLStudio.com> napisal w wiadomosci
news:IuidnYPgG6V6lnbX...@speakeasy.net...

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

unread,
Oct 30, 2009, 3:22:33 PM10/30/09
to

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

0 new messages