My question is maybe silly and will be not so easy to exactly write down. However may example understandable. I am creating a system logging database, which periodically stores values from a hardwer. My tables (in very reduced complexity) are:
VARIABLES table
id_variable name_variable
1 Temperatur
2 Voltage
... ...
n VariableN
LOG_ROWS table
id_log_row timestamp
1 2012.01.01. 10:00:00
2 2012.01.01. 10:01:00
3 2012.01.01. 10:02:00
n 2012.01.01. 10:0n:00
LOG_VALUES table
id_log_value id_log_row id_variable value
1 1 1 34
2 1 2 1200
3 2 1 35
4 3 1 36
5 3 2 1230
The data structure is important, because I have to add new variables later wothout alter table and each variable has other storing time period. (not all log_rows contains the all variable. Here time period of voltage is 2 min, time period of temperatur is 1 min)
So, I would like to create well readable db view, where the columns are the variable ids or names (here names) joined with log_row's id and timestamp. Something similar to this.
id_log_row timestamp Temperatur Voltage ... N
1 2012.01.01. 10:00:00 34 1200 NULL
2 2012.01.01. 10:01:00 35 NULL NULL
3 2012.01.01. 10:02:00 36 1230 ... NULL
Is these view possible with SQL? To define columns according to table content. I am interested in. I want to create this in SQLite
SQLite does not support altering a view. It is generally a bad idea to design your data is such a way that you later must alter tables.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.