I am doing a web app similar to SkyScanner and I have a database where I save single flight entities (origin, destination). Let's imagine the database have these 3 flight entities:
- BCN,MAD
- MAD,LON
- LON,MIA
The user asks for an itinerary between BCN(barcelona) and MIA(miami). How can I get this join? (Ignoring the number of stops for simplicity.) It needs to be dynamic solution as this is just an example and we can have thousands of flights entities in db.