mysql - Database schema: Key/Value table or all keys in one record -
I think this is part of the philosophical question. I need to collect pathology results for the group of patients and store them in the database. In the past, I have used a very simple table structure (simplified):
+ --- ---------------- + ---- ---------- + ------ + ----- + ----- ---- + ------- + | Field | Type | Faucet Key | Default | Extra | + ------------------- + -------------- + ------ + ----- + - -------- + ------- + | ID | Bilent (20) | No | PRI | Faucet | | Updated | Day-time No | PRI | Faucet | | Patient ID Varchar (255) | No | | Faucet | | Name | Varchar (255) | No | | Faucet | | Price | Varchar (255) | No | | Faucet | + ------------------- + -------------- + ------ + ----- + - -------- + ------- +
I look at the schema design more often:
+ - - ---------------- + -------------- + ------ + ----- + ---- ------ + ------- + | Field | Type | Faucet Key | Default | Extra | + ------------------- + -------------- + ------ + ----- + - -------- + ------- + | ID | Bilent (20) | No | PRI | Faucet | | Patient ID Varchar (255) | No | | Faucet | | Ph_Value | Varchar (255) | No | | Faucet | | K_Value | Varchar (255) | No | | Faucet | | Ca_Value | Varchar (255) | No | | Faucet | | Ph_Value_updated | Day-time No | | Faucet | | K_Value_updated | Day-time No | | Faucet | | Ca_Value_updated | Day-time No | | Faucet | + ------------------- + -------------- + ------ + ----- + - -------- + ------- +
It seems that the first design is more flexible, expandable. However, I wonder if the records run for millions when the performance hits.
The issue with the other is that there can be few hundred farms which should be recorded on occasions.
I would really be interested in getting comments / advice / guidance.
You are absolutely right, the first schema is very flexible: you can add new keys to change the schema Without a live database, however, flexibility is usually purchased with time and / or space. In this situation, it is both: You need more space to store all keys for the same line because < Code> id has been repeated N
bar, and appears The required order fields will take time to receive.
There is no reason to pay for flexibility unless you require it. If most of your questions require most columns, then the second result is the most economical, however, if most of your questions ask for a column, then getting the flexibility can be worth spending on CPU time and database space.
Comments
Post a Comment