.net - SQL - Can I base a table primary key on more than one field, requiring the uniqueness of first OR second value? -
.net - SQL - Can I base a table primary key on more than one field, requiring the uniqueness of first OR second value? -
let have product catalog. table has next fields: companyid , productid . want table primary key based on 2 fields, record unique when pair of companyid , productid fields have unique values. clear: record of cid = 1 , pid = 10 can coexist record of cid = 2 , pid = 10 (two companies may wish have product tagged same identifier, right?), can record of cid = 1 , pid = 9. of course of study 2 records both cid=1 , pid=10 values can not coexist. not want introduce column unique record identifier, because want these rules applied without creating c# layer checking integrity. hope understandable, tried clear somehow can't find words describe it.
yes, primary key on 2 column want. seek out.
.net sql database primary-key constraints
Comments
Post a Comment