简体   繁体   中英

ORM Database design for quiz website

I am trying to learn ORM and better structuring a database. I am working on a simply quiz web app to try to learn the relationships between tables. Am I on the right track here?

Down below are my tables. And I was thinking like this:

  • Question has one answer.
  • Answer belongs to many questions.
  • Question has many alternatives.
  • Alternatives belongs to many questions.

The tables

Question

  • ID
  • Question

Answer

  • ID
  • Answer

Alternatives

  • ID
  • Alternative

QuestionAlternative

  • QuestionID
  • AlternativeID

Consider a data model something like this:

ERD

You have a list of questions, each of which has zero, one or more offered options (possible answers). For each question, a user enters an answer. This answer may refer to a specific OPTION if applicable, or it could contain some kind of free-form information in the ANSWER table itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM