是的,一個數據庫可以很好地工作。
您將需要一個列來存儲日期或時間戳,以便您可以區分樣本結果。沒有這樣的專欄,「最近的測量」是沒有意義的。 (表格中行的順序本質上是沒有意義的。)
您可能不需要任何人開發前端;嘗試手動輸入數據或通過dbms的批量加載器加載CSV文件。 (每個現代dbms都有一個;它們的名稱各不相同)。
而且您可能不需要報告專家來構建報告。查詢輸出通常是研究中需要的。
一些查詢很簡單,其他查詢可能並不簡單,但至少很簡單。下面的代碼在PostgreSQL中進行了測試,但應該支持任何支持公用表表達式和行構造函數的dbms。
create table measurements (
sample_id integer not null,
measurement_time timestamp not null,
measurement real not null check(measurement >= 0 and measurement <= 30),
primary key (sample_id, measurement_time)
);
insert into measurements values
(1, '2012-02-02 08:03', 13.89),
(2, '2012-02-02 00:00', 13.86),
(1, '2012-02-02 00:25', 25.07),
(1, '2012-02-02 03:32', 25.38),
(1, '2012-02-02 05:47', 16.64),
(2, '2012-02-02 08:03', 16.16),
(2, '2012-02-02 07:25', 25.85),
(3, '2012-02-02 08:03', 14.78),
(3, '2012-02-02 09:29', 17.08),
(3, '2012-02-02 10:31', 13.41),
(4, '2012-02-02 12:38', 20.98),
(5, '2012-02-02 08:03', 25.00),
(5, '2012-02-02 14:02', 16.27),
(5, '2012-02-02 03:32', 12.10),
(5, '2012-02-02 17:47', 21.34),
(6, '2012-02-02 18:32', 17.16),
(6, '2012-02-02 18:33', 21.59),
(7, '2012-02-02 20:07', 21.47),
(8, '2012-02-02 21:58', 11.50),
(8, '2012-02-02 22:53', 21.01);
-- All samples with their highest measurement.
select sample_id, max(measurement)
from measurements
group by sample_id
order by sample_id;
-- Most recent measurement lower than any preceeding measurement.
-- Another way of saying this is that the max() measurement isn't the
-- latest measurement.
with max_measurements as (
select m.*
from measurements m
inner join (select sample_id, max(measurement) measurement
from measurements
group by sample_id) max_m
on max_m.sample_id = m.sample_id
and max_m.measurement = m.measurement
),
latest_measurement as (
select m.*
from measurements m
inner join (select sample_id, max(measurement_time) measurement_time
from measurements
group by sample_id) max_m
on max_m.sample_id = m.sample_id
and max_m.measurement_time = m.measurement_time
)
select m.*
from max_measurements m
where row(m.sample_id, m.measurement_time) not in (select sample_id, measurement_time
from latest_measurement);
那麼,到底你在問什麼? – 2012-02-05 21:11:00
YOu是對的,數據庫似乎是一個解決方案。現在,您需要一位設計數據庫的分析師。一個代碼開發人員,使用戶葉終端界面。還有一位報告專家來撰寫報告。我認爲你可以測試一些東西並分解問題。我投票結束。 – danihp 2012-02-05 21:12:00
Sample_id似乎不是唯一的。您至少需要第三欄包含數據+測量時間,甚至可能需要第二個表格。 – wildplasser 2012-02-05 21:15:08