是否有可能以某种方式在两个表之间进行多个一对多关系? 像:
表abc
表格def
如果是,我怎么能用实体框架创建一个新的abc条目?
答案 0 :(得分:2)
你只需要一个很多很多的关系。只需将QuestionId移出quiz_answers表并将AnswerId移出quiz_questions表:
Create Table quiz_questions
(
QuestionId ... Not Null Primary Key
, Question ...
, ...
)
Create Table quiz_answers
(
AnswerId ... Not Null Primary Key
, Answer ...
, ...
)
Create Table quiz_question_answers
(
QuestionId ... Not Null References quiz_questions ( QuestionId )
, AnswerId ... Not Null References quiz_answers ( AnswerId )
, Constraint PK_quiz_question_answers Primary Key ( QuestionId, AnswerId )
)
答案 1 :(得分:0)
是的,它是从abc到def的一对一连接,然后是从def到abc的另一个连接;所以abc在defID上加入def def,在abcID上加入def到abc。