Engo Engo - 4 years ago 110
MySQL Question

Converting medical datasheet into MySQL database design

I am trying to develop a medical symptom checker app and therefore I need to convert my excel datasheet which contains over 190k of records into a MySQL database. I have asked and read multiple related questions before, but I still find it difficult to create an efficient/proper database design.

Please take a look at the design of the app (1st image) to get an idea how the app works.

Steps user should follow to check symptom(s)


  1. User chooses gender, age and bodypart

  2. App shows all (common/less common) symptoms of chosen bodypart

  3. User chooses symptom

  4. Apps asks if there are more symptoms that apply (only if symptom has additional symptoms in database). User can tick up to 2 additional symptoms.

  5. App shows all (common/less common) diseases of chosen symptom and additional symptoms. The order (weight) of the diseases is dependent on the selected age, gender, bodypart, main symptom and selected additional symptoms.

  6. User chooses disease

  7. App shows disease information



Attributes:
age
,
gender
,
bodypart
,
symptom
,
disease



  • age
    : the app queries the database using id's; 0-5 is 1, 6-17 is 2, 18-59 is 3, 60+ is 4

  • gender
    : the app queries the database using id's; male is 1, female is 0

  • bodypart
    : the app queries the database using id's; 'Head front' is 1, 'Neck front' is 2 etc...

  • symptom
    : name, critical. critical is created to tell the user that he/she needs to contact their doctor immediately.

  • disease
    : name, critical, description, tests and treatment. critical is created to tell the user that he/she needs to contact their doctor immediately



I already have a database which contains all data and possible combinations of input/output. Unfortunately it is not designed to be used in an app (2nd image).
As you can see in the 2nd image, the order of the diseases (disease weight) is dependent on the selected age, gender, bodypart, symptom and selected additional symptoms (additional symptoms that apply). Each symptom may have up to 2 additional symptoms. The user can check either 0, 1 or 2 of the additional symptoms and the order of the disease will be different for each of these options.

Each symptom is either common (1) or less common (0). It depends on the user input (age, gender, bodypart).

Each disease weight <= 5 is considered to be a common disease. Diseases with weight > 5 are considered as less common diseases. Of course it is also depends on the user input (age, gender, bodypart, symptom, additional symptoms). I have tried so many things but I still don't know how to design this feature in a proper way.

Could anyone help me designing a suitable database?

UPDATE 1

Basically we need to keep 3 queries in mind when designing the database


  1. Get all symptoms (symptom.id, symptom.name, symptom.critical, symptom community (common/less common)) that belong to the combination of selected age = $age, gender = $gender AND bodypart = $bp

  2. Get all additional symptoms (symtpom.id symptom.name) of selected symptom

  3. Get all diseases (disease.id, disease.name, disease.critical disease weight) that belong to the combination of selected age, gender, bodypart, main symptom and additional symptoms.



App design
app design

Excel datasheet
excel datasheet

Answer Source

A Disease table is fairly simple; it contains columns H..O, with duplicates removed. Plus there is a unique ID for each row. (See AUTO_INCREMENT) I'm unclear on whether disease_weight belongs in the Disease table or somewhere else.

Symptoms might be best implemented as a SET datatype.

Another table contains columns of gender, age_range, body_part, symptoms, and disease_id (and maybe disease_weight).

The main SELECTs that I see are

 SELECT symptoms FROM table2
     WHERE age_range = $ar
       AND gender = $gender
       AND body_part = $bp
       AND FIND_IN_SET(symptoms, $symptom1);

To get the possible secondary symptoms.

(You have not explained how a user will enter an age_range; I assume that will end up in your cgi language as $ar. (Etc)

SELECT d.name, ...
    FROM Table2 t
    JOIN Diseases d ON d.disease_id = t.disease_id
    WHERE age_range ...
      AND symptoms & $symptoms;

(I may have a syntax error on the SET operators.)

If there are other SELECTs, you need to think about them now, not later.

You have not explained how this dataset will be updated; that could be an issue, too.

You did not actually ask how to get from Excel to MySQL; let's finish the database design first.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download