4

I am using MS SQL Server 2012. I have two tables, one for doctors and another for surgery centers. Each table currently contains columns that describe how they (doctors and surgery centers) should receive reports (email, fax...) The columns that hold this data in both tables are identical. I am thinking to pull the delivery method columns out of each table and make a common delivery method table, but I would need to have foreign keys for both the doctor and surgery center in each row. This is troublesome as there is a one to one relationship between the delivery method and the doctors. This same relationship exits for the surgery center table.

Question:

  1. Is it good practice to have a table with two foreign keys and one of them would always be null?
  2. What is the best strategy to handle such a case.

The reason I would like to pull the delivery method information from the doctors and surgery center tables is to reduce the overall size of the tables. Also this will better normalize my data. I appreciate any and all help and guidance.

4 Answers 4

1

A thought is to have a single DeliveryMethod table. Each record in this table will have an ID (probably surrogate - e.g. Identity or Sequence). Then, the Doctor table will have a DeliveryMethodID foreign key, and likewise the SurgeryCenter table will have a DeliveryMethodID foreign key.

In typical database design, you don't want two identical tables. If table size becomes an issue, there are various approaches to deal with this, including making it a partitioned table.

0

You have the relationship going from the delivery method to the dr/centers, instead of from the dr/center to the delivery method.

If you reverse the relationship, not only do you eliminate the need to have a table with a potentially unsed column, you can share delivery methods amoung multiple drs and centers. You say that there is a 1 to 1 relationship, but if there is not a business rule that PREVENTS a dr or center from having the same delivery method as any other dr or cent, then what you have is actually a many to 1 relationship (many dr/centers can have the same delivery method) even if in practice it is unique.

0

One option is to have two intermediate tables that link the PKs of DeliveryMethod table to Doctors and SurgeryCenter tables, so that, for example, DoctorDeliveryMethod has two columns : Doctor.id and DeliveryMethod.id.

This requires you to join three tables to get the methods for each, though. Another is to link the DeliveryMethod.id to a column in the Doctor table, call it DeliveryMethodID. You'll have to do the bookkeeping either way

0

A possible alternative design is:

  • Table 'DeliveryMethods': columns ID (PK), Fax_number, Email_Address, Preferred, ...
  • Table 'SurgeryCentres': columns SC_ID (PK), Name, ..., DeliveryMethodID (FK referencing DeliveryMethods), ...
  • Table 'Doctors': columns MD_ID (PK), Name, ..., DeliveryMethodID (FK referencing DeliveryMethods), ...

This avoids nulls but gives you normalized data.

Not the answer you're looking for? Browse other questions tagged or ask your own question.