How to deal with mutually recursive inserts

前端 未结 3 983
感情败类
感情败类 2020-12-16 05:35

I have a model that defines mutually recursive tables:

Answer
  questionId QuestionId
  text

Question
  text
  correct AnswerId

What do I

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 06:08

    I would insert into question, with a null correct AnswerId. Then I would insert into Answer, and finally I would update Question and set the correct answerId.

提交回复
热议问题