Diagram Desk

Survey ERD

Survey, question, choice and answer: a hierarchy (survey → questions → choices) with answers pointing at a choice.

The diagram

SurveyPK survey_id inttitle varcharQuestionPK question_id intFK survey_id intprompt varcharChoicePK choice_id intFK question_id intlabel varcharAnswerPK answer_id intFK choice_id intanswered_at datetimeasksofferschosen_in
ER diagram · 15 shapes

Reading it step by step

  • 'Survey' has 2 attributes, primary key survey_id.
  • 'Question' has 3 attributes, primary key question_id, foreign key survey_id.
  • 'Choice' has 3 attributes, primary key choice_id, foreign key question_id.
  • 'Answer' has 3 attributes, primary key answer_id, foreign key choice_id.
  • Each 'Survey' relates to one or more 'Question'; each 'Question' to exactly one 'Survey' (asks).
  • Each 'Question' relates to one or more 'Choice'; each 'Choice' to exactly one 'Question' (offers).
  • Each 'Choice' relates to zero or more 'Answer'; each 'Answer' to exactly one 'Choice' (chosen_in).

Shape by shape

ShapeSymbolConnections
SurveyEntityholds survey_id, title · → Question(asks)
QuestionEntityholds question_id, survey_id, prompt · → Choice(offers) · ← Survey
ChoiceEntityholds choice_id, question_id, label · → Answer(chosen_in) · ← Question
AnswerEntityholds answer_id, choice_id, answered_at · ← Choice

Symbols used here

SymbolMeaning
EntityA thing to store: name on top, attributes below.
Primary key (PK)The attribute that identifies one row; underlined.
Foreign key (FK)An attribute pointing to another entity's key.
Exactly oneTwo short bars at the line end.
Zero or manyA crow's foot and a circle.
One or manyA crow's foot and a bar.

All er diagram symbols and how to draw

Diagram text

Paste this text into the editor to get the same picture, then change the names to fit your own work.

# Survey ERD
erDiagram
  Survey {
    int survey_id PK
    varchar title
  }
  Question {
    int question_id PK
    int survey_id FK
    varchar prompt
  }
  Choice {
    int choice_id PK
    int question_id FK
    varchar label
  }
  Answer {
    int answer_id PK
    int choice_id FK
    datetime answered_at
  }
  Survey ||--|{ Question : asks
  Question ||--|{ Choice : offers
  Choice ||--o{ Answer : chosen_in

More er diagram examples

All SeewolLabs tools