D
D
Dmitry2017-09-24 17:14:26
MySQL
Dmitry, 2017-09-24 17:14:26

What is the best way to generate a list of cities in a form?

Good evening.
There is a form for drawing up a route. In addition to the name, route number, city of departure and city of arrival, it is necessary to record intermediate points of travel. There may be one or more of them.
Therefore, the question arose, how best to store the id of these items in the database?
1) In the route table, write all id of intermediate cities in one line.
2) Create an intermediate table where to write the route id and the id of each city.
Tell me, please, how will it be better?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Fortop, 2017-09-24
@Fortop

The second option will be better. Plus, do not forget to number the cities in this "intermediate" table.
Which is the de facto route-city link table

M
Maxim Fedorov, 2017-09-25
@qonand

it all depends on what you will do next with this route. If later you need to apply various algorithms to the route, then you should store the data in the database as an undirected graph , but if it’s just adding / outputting the route, then option 2 is quite suitable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question