Introducing FOREIGN KEY constraint 'c_name' on table 't_name' may cause cycles or multiple cascade paths

前端 未结 2 1936
走了就别回头了
走了就别回头了 2020-12-22 11:07

I have a database table called Lesson:
columns: [LessonID, LessonNumber, Description] ...plus some other columns

I hav

2条回答
  •  [愿得一人]
    2020-12-22 11:35

    Given the SQL Server constraint on this, why don't you solve this problem by creating a table with SelectionID (PK), LessonID, Next_LessonID, QualifyingScore as the columns. Use a constraint to ensure LessonID and QualifyingScore are unique.

    In the QualifyingScore column, I'd use a tinyint, and make it 0, 1, or 2. That, or you could do a QualifyingMinScore and QualifyingMaxScore column so you could say,

    SELECT * FROM NextLesson 
    WHERE LessonID = @MyLesson 
    AND QualifyingMinScore <= @MyScore 
    AND @MyScore <= QualifyingMaxScore
    

    Cheers,
    Eric

提交回复
热议问题