开发者

Postgres Table is foreign key to multiple tables

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)开发者_C百科

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?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜