I have three tables -
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
)
I want to ensure that when these are natural-joined, product_id + filename is unique. The best solution I have so far involves adding filename to the product_attachment table, but I'm wondering if there's a way to avoid that.