views:

47

answers:

2

I have a situation and would appreciate some help.
I have two tables - Error and Warning:

Error   : Err_no, pattern(pk=Error_no)
Warning : War_no, pattern(pk=War_no)

Based on these tables I have to decide on the resolution and I have a separate table doing this:

Resolution : Code_no, resolution

I want to keep Code_no as foreign key to both Err_no(Error table) and War_no(Warning table). I am using Postgres and want to know if and how I can do that?

+1  A: 

A foreign-key can reference one-and-only-one primary-key table - so you won't be able to have Code_no reference both tables.

Will A
I understand now. Thank you
learner
A: 

You can redesign you tables,merge tables Error and Warning to one table:Message

Message:(Msg_no,parrern,type(pk=Msg_no))

using column type to distinguish error or warning.then you can keep Code_no as foreign key to Message(Msg_no).

tinychen
yeah, I guess redesign would be a better option, thanks for pointing it out
learner