我有三张桌子 -
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
)
Run Code Online (Sandbox Code Playgroud)
我想确保当这些是自然连接时,product_id + 文件名是唯一的。到目前为止,我拥有的最佳解决方案是将文件名添加到 product_attachment 表中,但我想知道是否有办法避免这种情况。