Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Nader
Starting Member
41 Posts |
Posted - 2010-06-21 : 15:27:55
|
| I have the following tablesquestion(questionid,questioncontent,etc)quiz (quizid, title,etc)section (sectionid, etc)sectionquiz (sectionid,quizid,etc)sectionquizquestion(sectionid,quizid,questionid,etc)sectionquizquestionstudans(sectionid,quizid,questionid,studans,etc)is it better performance wise to create a composite foreign key (sectionid,quizid,questionid)that links sectionquizquestionstudans to sectionquizquestionor three foreign keyssectionid links sectionquizquestionstudans to sectionquizid links sectionquisquestionstudans to quizidquestionid links sectionquisquestionstudans to questionI do have already a foreignkey that links sectionquiz to sectionidand another that links sectionquiz to section |
|
|
lazerath
Constraint Violating Yak Guru
343 Posts |
Posted - 2010-06-21 : 18:01:22
|
| It sounds to me that this question is not mutually exclusive. In other words, you may want to add both the 'composite' in addition to the three separate foreign keys.You should use foreign keys to reflect the relationships in your logical and physical data models. If you want there to be a constraint requiring sectionquizquestionstudans to have a corresponding row in sectionquizquestion and the foreign key is legitimately a composite (sectionid,quizid,questionid), by all means add that to the database! Likewise, add relationships to section, quizid, and question as appropriate.Unless you really know what you are doing and you have a specific situation that calls for every last ounce of throughput, performance is a non issue compared to the potential for orphaned rows and data issues. |
 |
|
|
|
|
|
|
|