I have a database table called Lesson
:
columns: [LessonID, LessonNumber, Description]
...plus some other columns
I have another table called Lesson_ScoreBasedSelection
:
columns: [LessonID,NextLessonID_1,NextLessonID_2,NextLessonID_3]
When a lesson is completed, its LessonID is looked up in the Lesson_ScoreBasedSelection
table to get the three possible next lessons, each of which are associated with a particular range of scores. If the score was 0-33, the LessonID stored in NextLessonID_1 would be used. If the score was 34-66, the LessonID stored in NextLessonID_2 would be used, and so on.
I want to constrain all the columns in the Lesson_ScoreBasedSelection
table with foreign keys referencing the LessonID column in the lesson table, since every value in the Lesson_ScoreBasedSelection
table must have an entry in the LessonID column of the Lesson table. I also want cascade updates turned on, so that if a LessonID changes in the Lesson table, all references to it in the Lesson_ScoreBasedSelection
table get updated.
This particular cascade update seems like a very straightforward, one-way update, but when I try to apply a foreign key constraint to each field in the Lesson_ScoreBasedSelection
table referencing the LessonID field in the Lesson table, I get the error:
*Introducing FOREIGN KEY constraint 'c_name' on table 'Lesson_ScoreBasedSelection
' may cause cycles or multiple cascade paths.*
Can anyone explain why I'm getting this error or how I can achieve the constraints and cascading updating I described?