What is causing this sqlite foreign key mismatch?

后端 未结 1 1473
太阳男子
太阳男子 2020-12-19 01:41

I already checked out this question, and thought I had the answer - but then it didn\'t look right to me.

I have the following pared down example:

CR         


        
相关标签:
1条回答
  • 2020-12-19 01:57

    The documentation says:

    Usually, the parent key of a foreign key constraint is the primary key of the parent table. If they are not the primary key, then the parent key columns must be collectively subject to a UNIQUE constraint or have a UNIQUE index.

    In the pipelines table, neither the name nor the owner columns are, by themselves, unique.

    I guess you actually want to have a two-column foreign key in the tasks table:

    FOREIGN KEY(pipeline, owner) REFERENCES pipelines(name, owner)
    
    0 讨论(0)
提交回复
热议问题