sql server - Foreign Key column issue -


i trying connect 2 tables using foreign key.

table 1: (plaque):

plaque_id   plaque_type      facility_id    facility    plaque_sub_location 2468        lettering         26          gorab building    donor wall friend level 2469        lettering         36          abc hospital  music & entertainment wall 2476        facility plaque   46          abc hospital  1st fl office room 

table 2: facility

facility_id facility             facility_desc  plaque_id 26          gorab building                         2468 36          abc hospital                           2469 46          abc hospital                           2476 

i don't want facility table have same rows plaque table. want distinct names in facility column. thought way make facility column foreign key plaque table confused because can make such column foreign key. have seen id columns foreign keys. reason behind distinct values in facility column because every row have large description facility in facility_desc column.

an answer appreciated.

you don't need plauque_id in facility table because have facility_id in plaque table , enough make connection between plague , facitlity tables. use simple join. example:

select plaque_id, plaque_type, facility plaque inner join facility on plaque.facility_id = facility.facility_id  

i thik should set facility column of facility table unique , remove facility column of plaque table. remember plaque table should describe plaque properties onlu. consider adding new plaquetype table , replacing plaque type column of plaque id coresponding foreign key ot plaquetype table.

here simple explanation of how join tables http://www.w3schools.com/sql/sql_join_inner.asp


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -