PeakGen
PeakGen

Reputation: 23005

How to design tables when data can be divided into categories but all are belong to one common category?

In my database I have tables called patient and target_metrics. The target_metrics table shows the metrics related to the patient.

The "metrics" are divided into 3 categories. They are,

  1. glucose
  2. measurements
  3. activity

All of these are "belongs" to the patient.

So I divided these sections into separate tables, like below. In the below image, I have removed the field names for privacy reasons.

enter image description here

Anyway, I also do believe that it will be very easy for implementations if we remove the entire target_metric table and link all other tables directly to patient. All of these tables will contain a one record per one patient, forming a one-to-one relationship.

In your experience, what would be the advice? Keep it as in image or remove target_metric by linking the other tables to patient?

Upvotes: 0

Views: 105

Answers (1)

juergen d
juergen d

Reputation: 204746

Loose the target_metric table. Also loose the extra id column:

target_metric_glucose table
---------------------------
patient_id
...

Where patient_id is foreign and primary key in the table.

Upvotes: 2

Related Questions