Relationship Database

Asked

Viewed 45 times

3

I’m having doubts about the relationship in the following case: I have the Question table and the Answer table. 1 Question may have N Answers. 1 Answer may be for N Questions. Can it be said that the relationship is N:N ? If yes, as the third table, the relationship table between the two ?

1 answer

5

Yes, "N:N".

Simply a table with 3 fields: id, id_question, id_answer - and preferably everything should be an index, so you can do the two-way search.

Depending on how you are using, you will not need the "id".

  • 1

    I always recommend having an isolated primary key as the id in case you need to delete, in addition to being faster for the bank with the single index, also gives more security to work. It may give problems in some situations if you are upgrading too.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.