【发布时间】:2014-07-23 12:08:07
【问题描述】:
我有三张桌子 -
file (
file_id int primary key
filename text not null
etc...
)
product (
product_id int primary key
etc....
)
product_attachment (
product_id references product
file_id references file
)
我想确保当这些是自然连接时,product_id + 文件名是唯一的。 到目前为止,我最好的解决方案是将文件名添加到 product_attachment 表中,但我想知道是否有办法避免这种情况。
【问题讨论】:
标签: sql postgresql foreign-keys unique-constraint