TRC: Select an ID if it appears on all measurements
2
votes
1
answer
73
views
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.
Asked by Itay
(123 rep)
May 6, 2014, 06:20 AM
Last activity: May 2, 2018, 05:43 PM
Last activity: May 2, 2018, 05:43 PM