Hey, gang:
One of the things that relational databases don't do very well is ordered lists, where the order isn't an expression of some aspect of the data.
In other words, if you were planning a bus route, and you had a list of addresses:
2003 Birch Ave
1234 Main Street
221B Baker Street
425 Elm Street
then the database would happily put these into a numeric/alpha order:
221B Baker Street
425 Elm Street
1234 Main Street
2003 Birch Ave
But if you're planning a bus route, you might want these in a different order, say, most efficient route:
425 Elm Street
2003 Birch Ave
1234 Main Street
221B Baker Street
The problem is, because you can't express arbitrary order, you have to add some value to the records to get them in the order you want.
1,425 Elm Street
2,2003 Birch Ave
3,1234 Main Street
4,221B Baker Street
The problem comes when you then want to insert sometihng in the middle of the list, say adding a new house between Birch and Main:
1,425 Elm Street
2,2003 Birch Ave
?,1504 Spruce Street
3,1234 Main Street
4,221B Baker Street
So, I'm wondering what other people do in this situation? Right now, my approach is to take the list into memory, let the user make whatever changes, completely purge it from the database and enter it with the new sequence.
Not a great solution, but works in this case.
One of the things that relational databases don't do very well is ordered lists, where the order isn't an expression of some aspect of the data.
In other words, if you were planning a bus route, and you had a list of addresses:
2003 Birch Ave
1234 Main Street
221B Baker Street
425 Elm Street
then the database would happily put these into a numeric/alpha order:
221B Baker Street
425 Elm Street
1234 Main Street
2003 Birch Ave
But if you're planning a bus route, you might want these in a different order, say, most efficient route:
425 Elm Street
2003 Birch Ave
1234 Main Street
221B Baker Street
The problem is, because you can't express arbitrary order, you have to add some value to the records to get them in the order you want.
1,425 Elm Street
2,2003 Birch Ave
3,1234 Main Street
4,221B Baker Street
The problem comes when you then want to insert sometihng in the middle of the list, say adding a new house between Birch and Main:
1,425 Elm Street
2,2003 Birch Ave
?,1504 Spruce Street
3,1234 Main Street
4,221B Baker Street
So, I'm wondering what other people do in this situation? Right now, my approach is to take the list into memory, let the user make whatever changes, completely purge it from the database and enter it with the new sequence.
Not a great solution, but works in this case.
Comment