Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 ideas on foreign key

Author  Topic 

rajani
Constraint Violating Yak Guru

367 Posts

Posted - 2004-05-13 : 22:30:06
Hi friends
I've table Task with following flds

taskid,type,fk_id

if type='I' then it referes to another table i.e Master.pkey
if type='T' then it referes to another table i.e Transact.pkey

my question is, is it possible to create a condition foreign key on task table?
Thanks for ur ideas


Cheers

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-05-13 : 22:37:57
No. You can have a logical key, meaning on that's not enforced and interpreted by your application to determine the table it's from. You need to have two foreign keys. You could also break the tasks out for Master and Transact, then have a table that joins the Master tasks to the Transact tasks.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

rajani
Constraint Violating Yak Guru

367 Posts

Posted - 2004-05-13 : 22:41:49
Thanks for quick reply Derrick
May b i need to split fk_id field into 2 fields
and one refers to Master.pkey and other referes to Transact.pkey
am i right?

Cheers
Go to Top of Page
   

- Advertisement -