0

Using MySQL

I need help determining how to model a Keywords table to three different tables (Products, Certifications, and Exams) - I have included my model which is using what I refer to as intermediary tables (what would they be called), but im not sure that is correct. Can someone tell me if this is correct, or show me an example of how to do it correctly? Thank You!

Data model

2

Your design is correct. Tables with many to many relationship needs to have an interface table. Interfaces table contains foreign keys to the main table, it must have a primary key. Good luck

  • Can you explain what you mean with "it must have an ID field"? What is "it"? – ypercubeᵀᴹ May 10 '13 at 23:47
  • hello, yeah, Answer edited. I should have said the primary key.... thanks – coditori May 11 '13 at 6:57
0

You need three more constraints on each of your linkage tables. The first constraint says the the two FKs, taken together, are unique. The other two constraints say that neither of the FKs can be NULL.

If your linkage tables had declared a composite PK consisting of the two FKs, you would have gotten the same effect with just one constraint. The Id on the linkage tables would then be unnecessary. The consequences of a composite PK on performance is another question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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