Survey ERD
Survey, question, choice and answer: a hierarchy (survey → questions → choices) with answers pointing at a choice.
The diagram
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
| Shape | Symbol | Connections |
|---|---|---|
| Survey | Entity | holds survey_id, title · → Question(asks) |
| Question | Entity | holds question_id, survey_id, prompt · → Choice(offers) · ← Survey |
| Choice | Entity | holds choice_id, question_id, label · → Answer(chosen_in) · ← Question |
| Answer | Entity | holds answer_id, choice_id, answered_at · ← Choice |
Symbols used here
| Symbol | Meaning |
|---|---|
| Entity | A 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 one | Two short bars at the line end. |
| Zero or many | A crow's foot and a circle. |
| One or many | A crow's foot and a bar. |
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