Relational Calculus
You're on the right track.
- Free variable:
p_id
(determines your output structure) - Bounded variables:
f_no1
,f_no2
,f_date
You can see that there are two lines that look very similar, but differ significantly. Each line is pairing information across two relationships with the intention to find values that satisfy the conditions.
Notice that the f_date
and p_id
variables are the same on both lines, whereas f_no
differs. This indicates that there are two separate flights which occur on the same day with the same passenger on both. The first line indicates a journey from Rapanui to Papeete and the second line indicates a journey from Papeete to Auckland. Both of these journeys must also satisfy the requirement of being traveled via Economy class.
Bring this information together, this query is asking for the p_id
's where that p_id
travels from Rapnui to Auckland via Papeete on the same day, with both being in Economy class.
Relational Algebra
You pretty much have it there. The query selects p_id and p_name of all passengers who have flown to Los Angeles in Business class.