Skip to content

← Back to post

Best Practices: Semantic Data Model

10/12/2025

Semantic Data Model (Markdown)

Download Markdown

Semantic Data Model for an Online Survey

Overview

The following semantic data model describes the structure and relationships of the entities required to manage and conduct an online survey. It covers the definition of surveys, questions, answer options, survey responses, and optional personal details of respondents.

  • Survey: Holds metadata of a specific survey.
  • Question: Defines the individual questions of a survey.
  • AnswerOption: Represents predefined answer options per question.
  • SurveyResponse: Stores a completed survey.
  • ResponseAnswer: Links a survey result with the answers to its questions.
  • Respondent: Optional, personal details about a participating person.
  • Enumerations: GenderEnum, AgeGroupEnum, QuestionTypeEnum.
erDiagram Survey ||--o{ Question : "contains" Question ||--o{ AnswerOption : "has" SurveyResponse ||--|| Survey : "belongs to" SurveyResponse ||--|{ ResponseAnswer : "consists of" ResponseAnswer ||--|| Question : "answers" ResponseAnswer }o--|| AnswerOption : "selects" SurveyResponse }o--|| Respondent : "associated with" Respondent }o--|| GenderEnum : "has" Respondent }o--|| AgeGroupEnum : "has" Question }o--|| QuestionTypeEnum : "has"

Entities

Survey

AttributeData TypePKFKRequired?DescriptionNotes/Constraints
SurveyIDUUIDxyesUnique identifier of the survey.Generated as UUID.
TitleString (max. 200)yesTitle of the survey.Not empty; trimmed.
DescriptionText (max. 2000)noDetailed description and purpose of the survey.Optional; trimmed.
StartDateDatenoStart date when the survey becomes active.ISO 8601 (YYYY-MM-DD).
EndDateDatenoEnd date until which the survey can be answered.ISO 8601 (YYYY-MM-DD); ≥ StartDate.
CreatedByString (max. 100)yesCreator (e.g., name or organization).Not empty; trimmed.
CreatedAtDate/TimeyesTimestamp of creation.Automatically set; ISO 8601 (UTC).

Question

AttributeData TypePKFKRequired?DescriptionNotes/Constraints
QuestionIDUUIDxyesUnique identifier of the question.Generated as UUID (UUIDv4).
SurveyIDUUIDxyesForeign key to the survey this question belongs to.FK; references existing Survey.
OrderNumberIntegeryesOrder of the question within the survey.Integer ≥ 1; unique per Survey.
QuestionTextText (max. 1000)yesWording of the question.Not empty; trimmed.
QuestionTypeEnumyesType of question. Determines whether rating scale, choice, or free text is allowed.See enum QuestionTypeEnum.
IsMandatoryBooleanyesIndicates whether the question must be answered.

AnswerOption

AttributeData TypePKFKRequired?DescriptionNotes/Constraints
OptionIDUUIDxyesUnique identifier of the answer option.Generated as UUID (UUIDv4).
QuestionIDUUIDxyesForeign key to the related question.FK; references existing Question.
OptionTextString (max. 200)yesText of the answer option (e.g., “Very good”).Not empty; trimmed.
ValueString (max. 100)yesValue stored internally for this option.Unique per Question; regex: ^[A-Za-z0-9_-]+$.
IsOtherOptionBooleannoMarks whether this is a free‑text option.Set to true for “Open” questions.

SurveyResponse

AttributeData TypePKFKRequired?DescriptionNotes/Constraints
ResponseIDUUIDxyesUnique identifier of the survey result.Generated as UUID (UUIDv4).
SurveyIDUUIDxyesForeign key to the survey.FK; references existing Survey.
RespondentIDUUIDxnoReference to the optional respondent.GDPR‑relevant; if set → ConsentGiven = true.
SubmittedAtDate/TimeyesSubmission timestamp.Automatically set; ISO 8601 (UTC).
ConsentGivenBooleanyesIndicates whether the respondent consented to processing personal data.Must be true if personal data present (RespondentID, Email, GenderCode, AgeGroupCode).

ResponseAnswer

AttributeData TypePKFKRequired?DescriptionNotes/Constraints
AnswerIDUUIDxyesUnique identifier of the answer.Generated as UUID (UUIDv4).
ResponseIDUUIDxyesForeign key to the survey result.FK; references existing SurveyResponse.
QuestionIDUUIDxyesReference to the answered question.FK; references existing Question.
OptionIDUUIDxnoSelected answer option (choice questions).May be set only when QuestionType != Open; must belong to QuestionID.
FreeTextResponseText (max. 2000)noFree‑text answer (open questions only).May be set only when IsOtherOption or QuestionType = Open.

Respondent

AttributeData TypePKFKRequired?DescriptionNotes/Constraints
RespondentIDUUIDxyesUnique identifier of the respondent.Generated as UUID.
EmailString (max. 254)noRespondent’s email address.GDPR‑relevant; optional; format: email (RFC 5322); regex example: ^[^\s@]+@[^\s@]+.[^\s@]{2,}$.
GenderCodeEnumxnoGender specification.See enum GenderEnum; optional; default: NotSpecified.
AgeGroupCodeEnumxnoAge group of the respondent.See enum AgeGroupEnum; optional; default: NotSpecified.
CreatedAtDate/TimeyesCreation timestamp of the respondent record.Automatically set; ISO 8601 (UTC).
LastConsentChangeAtDate/TimenoTimestamp of last consent change.ISO 8601 (UTC); ≥ CreatedAt.

Enumerations

NameValuesDescription
GenderEnumMale, Female, NonBinary, NotSpecifiedRespondent’s gender specification.
AgeGroupEnumAge_0_18, Age_19_35, Age_36_60, Age_61_99, NotSpecifiedRespondent’s age group.
QuestionTypeEnumRating, SingleChoice, MultipleChoice, OpenType of question.