I have model waypoint with two attributes
- coordinates
- geocode_text
And model route that is no more than sorted array of waypoints with some additional text info. Some routes can have same waypoints, so I want to separate waypoints from routes.
What is the best way to store waypoints inside route?
I see several ways:
- serialize waypoints ids to
waypoint_idsattribute ofroute, but in such situation I will not be able to get route and all his waypoints in one SQL request, because waypoint ids will be hidden in serialized string. create some third model that have such arguments
- route_id
- waypoint_id
- position
Connect routes and waypoints with many-to-many association and store position of waypoint in route in
positionattribute. But it seems to be over-complicated.
What is the best way for me in such situation?