I came across pretty simple and probably very basic problem, and I can't decide what solution is the best.
After simplifiyng my scheme to the bone, I have this:
- table of
Suppliers (id, name) - table of
Parts (id, name) - m to n table
PartSuppliers(supplier_id, part_id, price)
I need to mark one of the suppliers as primary supplier for given part. I see two options:
1) (currently used)
Add primary_supplier_id column to Parts table
2) Add column is_primary to PartSuppliers table
Both solutions have some pros and cons. Solution 1) there are problems with validation and CRUD - info about part suppliers is on "two places". Solution 2 would be easier to use in app, but isn't it breaking normalization?
is_primaryboolean column and a partial unique, assuming you are on a DBMS that has such indexes (eg. PostgreSQL, SQL Server). – ypercubeᵀᴹ Aug 02 '16 at 13:24