Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Big Survey Database Implementation Design Recomandations

$
0
0
Hello everyone, I'm a 2nd year student in Data Processing Engineering and I have recently started a side project involving a survey database for an health care center running on a MySQL server and managed by a custom software.

I did made many research and read many post and articles on survey databases in and outside this forum witch helped me extensively, but I still need some recommendations. I do have some specials element in my specific implementation that would need review from you guys.

Here is a descriptions of the project:

-Surveys with Questions.
-3 types of Answers (Yes/No, Full Answers, Scaled).
-Many Answer Options will be available for Scaled.
-Answers will be coming from multiple sources (Kiosk, Web Site, Tablets & Scanned*)
*I made a software that can get the answers from a scanned survey page and send them to the DB.
-Anything and everything must be filterable so that the software can create any kind of reports.
-Multiple Questions can be assigned to multiple Surveys.
-Multiple Surveys can be assigned to multiple Sources.

I would need recommendations on:
-Variable types.
-Tables & liaisons to them.
-Overall design.

Here is my SQL:

Code:

CREATE DATABASE surveydb;

CREATE TABLE Questions
(
questionID INT NOT NULL AUTO_INCREMENT,
question VARCHAR(255) NOT NULL,
type ENUM("Yes/No", "Full Answers", "Scaled"),
CONSTRAINT Questions_pk PRIMARY KEY (questionID)
);

CREATE TABLE Sources
(
name VARCHAR(255) NOT NULL,
CONSTRAINT Sources_pk PRIMARY KEY (name)
);

CREATE TABLE Surveys
(
name VARCHAR(255),
CONSTRAINT Surveys_pk PRIMARY KEY (name)
);

CREATE TABLE Options
(
name VARCHAR(255),
CONSTRAINT Options_pk PRIMARY KEY (name)
);
EDIT:Changed option var to name, option is a mysql reserved word. *Not changed in the diagram image.

CREATE TABLE SurveysQuestions
(
question INT NOT NULL,
survey VARCHAR(255) NOT NULL,
CONSTRAINT SurveyQuestions_pk PRIMARY KRY (question, survey),
CONSTRAINT SurveysQuestionsQ_fk FOREIGN KEY (question) REFERENCES Questions(questionID),
CONSTRAINT SurveysQuestionsS_fk FOREIGN KEY (survey) REFERENCES Surveys(name)
);

CREATE TABLE QuestionsOptions
(
question INT NOT NULL,
option VARCHAR(255) NOT NULL,
CONSTRAINT SurveyQuestions_pk PRIMARY KRY (question, option)
CONSTRAINT QuestionsOptionsQ_fk FOREIGN KEY (question) REFERENCES Questions(questionID),
CONSTRAINT QuestionsOptionsO_fk FOREIGN KEY (option) REFERENCES Options(option),
);

CREATE TABLE SourcesSurveys
(
source VARCHAR(255) NOT NULL,
survey VARCHAR(255) NOT NULL,
CONSTRAINT SurveyQuestions_pk PRIMARY KRY (source, survey)
CONSTRAINT SourcesSurveysSO_fk FOREIGN KEY (source) REFERENCES Sources(name),
CONSTRAINT SourcesSurveysSU_fk FOREIGN KEY (survey) REFERENCES Surveys(name),
);


CREATE TABLE Answers
(
answerID INT NOT NULL AUTO_INCREMENT,
question INT NOT NULL,
answer VARCHAR(255) NOT NULL,
survey VARCHAR(255) NOT NULL,
source VARCHAR(255) NOT NULL,
answerDate DATETIME NOT NULL,
CONSTRAINT FullAnswer_pk PRIMARY KEY (answerID),
CONSTRAINT FullAnswerQuestion_fk FOREIGN KEY (question) REFERENCES Questions(questionID),
CONSTRAINT FullAnswerCenter_fk FOREIGN KEY (center) REFERENCES Centers(name)
);

Here is a diagram of it:
Attachment 14640

As you can see this is almost done but by lack of experience I wanted to get some help.

Thank you very much to anyone that is willing to help. :beer:

Attached Images
File Type: png SurveyV3.png (32.0 KB)

Viewing all articles
Browse latest Browse all 13329

Trending Articles