I am pretty new to PostGIS and I have a problem I just can't figure how to start. I have a table of lines (id, name, the_geom) and a table of points (id, name, the_geom). Each point is located on a line and a line might have one or more points etc. The points can be located anywhere along the line, not just at vertices.
How can I create new lines from each line using points along the line given just the lines and points tables. For example, line ABCDEFG is a single line with its unique name and unique id in the lines table. How can I create new lines AB, BC, CD, DE, EF, FG such that they all have the same name as line ABCDEFG but different id, and load their new geometry into a new table of lines using PostGIS? Note that A and G are the start and end of line ABCDEFG and not actual points in the points table.
Example 1:
This is not an answer, but an attempt to explain the question better, following Chris' comment.
@Chris, the links you gave are nice but quite different from what I want to achieve. I am not trying to get the individual segments of lines based on the vertices of the lines themselves. What I am trying to achieve is to make sublines from lines based on where points from a different table intersect the lines. I think my diagram is a bit confusing, I have uploaded something better.