Database design: how to store the voltage of the lamps?
The database stores information on lamps. Most lamps have a nominal voltage, but some have a permissible range.
How is it better to keep voltage information on OBD and why?
- Two fields decimal (sighs)v_min, v_max) If the rated voltage is indicated, either keep the same values in both fields or leave one of the fields empty.
- Two fields decimal♪ First at rated voltage, which also describes the mean voltage if there is a range. Second, under (max-min)/2 (percentage) null default).
- One field varcharwhich stores either one digit or range
- Create two daughter tables - one to the rated voltage, the other to the range.
Any other options?
table (id int, min int not null, -- номинальное напряжение max int null -- максимальное напряжение )
Why is that? Imagine that in Table 1 billion of records, the lamps that can work with a certain voltage and return the sum (max - min) should be selected. If the data are stored in a varchar field, the lines will have to be converted into numbers when requested.