A
A
AlexSer2018-02-20 15:53:19
MySQL
AlexSer, 2018-02-20 15:53:19

What is the best way to organize DB tables and models in Yii2?

Guys such a problem. There are laboratory tests.
Simple and compound (as I separate in my head). Well, for example, ALT, AST .... they require one field for the result .. there are 30 such analyzes. And there are components Complete blood count (KLA form which contains 10 fields erythrocytes monocytes, etc.), Urinalysis (OAM form also contains 10 fields ), blood clotting and I have about five such tables ...
The question is how best to organize the tables for these tests?
Option 1 - each analysis has its own table. Thus, I will have 40 pieces. Each analysis has its own table. Good for reports.
2 Option to create 1 table for simple analyzes and for compound analyzes each has its own table ... the number of tables will be reduced, but the problem remains, that you will have to add a condition for each call ..
, but the number of tables will be used 10 pieces for all laboratory analyses.
Which option to choose please advise?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
davidnum95, 2018-02-20
@AlexSer

Three tables are enough:

analyze
id | name | type

property 
id | type | name

analyze_property_value 
id | property_id | analyze_id | value

A
AlexSer, 2018-02-20
@AlexSer

Everything is fine, but with the reports, how is it here? If there is only one analiz_id for composite analyses... how will I take the reports?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question