I am structuring a set of databases which all interconnect and contain information about each other. One of the main functions of the databases is to record paths and endpoints, for example;
Path 1 crosses endpoints point_1, point_2, point_3, point_4 and point_5
Path_1
= p1-p2-p3-p4-p5
Path 2 crosses endpoints point_1, point_2 and point_5
Path_1
= p1-p2-p5
Database Structure:
path_id | start_point | point_1 | point_2 | point_3 | end_point |
--------|-------------|---------|---------|---------|-----------|
1 | p_1 | p_2 | p_3 | p_4 | p_5 |
2 | p_1 | p_2 | | | p_5 |
And so on...
My problem is that I won't always know how many points it's going to cross. It could be 5 or it could be more than 15. How do I structure a database so that I could allocate a variable amount of points? (Path order is important)
To add to this, each point-point path also have an id associated with it. For example p1-p2
= 0001
and p2-p3
= 0002
Also how would I structure an SQL statement? At some point I want to query all of the paths that cross specific points, and if I have too many points I'm afraid I don't know how to create a statement so long.
This is probably a wrong database setup for this needs, any other suggestions are welcomed