TRC: Select an ID if it appears on all measurements
-
02-11-2019 - |
문제
I have these two "tables":
Station (station_id, city) // Stations details
Rainfall (station_id, date, amount) // Rainfall measurements
With Tuple Relational Calculus (TRC), I need to get the IDs of all stations that have related measurements on every date in which any measurement was taken.
So with the following tables I'm supposed to select 5
because this station has measurements on every date that has a measurement.
Station Rainfall
------- --------
--station_id-----city-- --station_id-----date-----amount--
5 LA 5 01/01 4
7 NY 7 02/02 8
5 02/02 3
I've tried this but I'm not quite sure if this would work if there are no measurements at all (in this case I'm supposed to select all station IDs):
{ t | ∃s ∈ Station (t[station_id] = s[station_id] ∧
∀r ∈ Rainfall (∃q ∈ Rainfall (r[date] = q[date] ∧ s[station_id] = q[station_id])) ) }
I need your help in understanding if what I did is correct.
올바른 솔루션이 없습니다
제휴하지 않습니다 dba.stackexchange