Is it possible somehow to do multiplie one-to-many relationships between 2 tables? Like:
Table abc
- abcID
- defID
- message
Table def
- defID
- abcID
- message
If yes how can I then make a new abc entry with the entity framework?
Is it possible somehow to do multiplie one-to-many relationships between 2 tables? Like:
Table abc
Table def
If yes how can I then make a new abc entry with the entity framework?
You only need a single Many-Many relationship. Simply move QuestionId out of the quiz_answers table and move AnswerId out of the quiz_questions table:
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 )
)
Yes, it is a one-to-one join from abc to def and then another from def back to abc; so abc joins to def on defID and def joins to abc on abcID.