Case Study of Database Design

Today, I want to share some database design tips with a case study, that I learned from my mentor. Every week or alternate week He gives us a use case and tells us to design a database for it. Sometimes the Data is in the Tabular format, Sometimes it is a simple word document. Here I am sharing one of that use case

Case Study:

My mentor gave us a document that consists of A set of Survey Questions divided into Sections, and there are multiple options for those Questions. So They were all multiple-choice questions.

Sample Raw Data: Below is the sample data. So we need to design data to store these Questions and Their Answers and User Responses.

Database Assignment.docx (17.78 kb)

 

Client Requirements:

You get requirements from the client, and then you start to design a database for the clients. So according to those requirements, you categorized the data. So here in the case study lets assume some of the requirements

  1. Need to store every user response and user info
  2. Need to store questions and answers
  3. Every Question can repeat in multiple sections

Data Analysis: 

Key Points to keep in mind Before Database Design:

  1. Performance of Database Queries 
  2. Cost of maintaining it

Analysis of the sample data:

  1. There are multiple sections in it, meaning our Survey has been divided into Sections.
  2. Every Section has several Questions there. And every question has a set of answers.
  3. Some questions have answers as “yes”, “no”, “sometimes” and those Answers are repeated for the Many Questions.
  4. Some questions have a set of the answer which are not repeating for any other questions.

Possible Real-life Data:

  1. In our sample data, we only have multiple-choice questions. But in surveys, we can get multiple choice questions, single choice questions, and subjective questions/ user inputs
  2. User information

Database Design:

Here is my design for the given data.

Below are the tables, their columns, and their relationship.

PK- Primary Key

FK- Foreign Key

 

 

  • UserInfo- to store User Info
  • UserResponse- to store user responses
  • QuestionInfo and AnswerInfo- For Question and answer information, Types are to differentiate the question and answer type.
  • SectionQuestionRelation- To allow "many to many" relation between Section and Question[ To support one question in multiple sections]
  • QuestionAnswerRelation - So multiple Answers can be related to multiple questions. And if any Question is subjective it will only present in the QuestionInfo table and not in the QuestionAnswerRelation table.
  • OfferedAnswer-  For User Input Answers 

Note: Here I have shared my design. There can be multiple correct designs for the current set of data and requirements. 

Thank You, Hope this is helpful.

 

 

 

Add comment