sql - I need to set as foreign key which refers to one of the composite primary key in other table -


i have 3 tables composite primary keys, need set foreign key refers 1 of primary key in other table.

ie,

  • table 1: merchant(mid,mname,addid,..) pk(mid ,addid) .
  • table 2: address(addid,name..) pk(addid)
  • table 3: store(storeid,addid,mid,storename,..) pk(storeid,addid,mid)

mid in table store foreign key primary key mid of merchants table, addid in tbl store foreign key primary key in table address.

how relationship set in sql server management studio express using gui?

your constraints work this, i.e. in cascading style:

alter table store add constraint fk_store_merchant foreign key (mid, addid) references merchant (mid,addid) alter table merchant add constraint fk_merchant_address foreign key (addid) references address (addid) 

not sure how in gui, run query window.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -