I'm developing a fleet scheduling application and look for an effective way to store distances between geographic locations.
The application-code accesses the matrix as a two-dimensional array double[,]
.
In order to make the matrix persistent, I currently serialize the matrix as a string. After serialization it looks like this:
"1 4 9 8 3 6 \n
5 6 7 9 3 6 \n
34 4 5 6 6 7 \n"
Then it is stored in a column of type varchar(max)
in a SQL Server 2008 database. However, I wonder if this string could get too big.
Assuming that each entry has one digit and neglecting white-spaces and "\n"s, theoretically I could store the distances of around 46000 locations (square-root of 2 147 483 647 - the size of varchar(max)
) in one entry. This would be sufficient in my context.
Does this approach have any severe disadvantages? Would it be better to store distances in an extra table, where each row contains one distance between two locations?
If 100 users of our application stored 1000 locations respectively, I would have 100000000 = 100 * 1000 * 1000 rows in such a table....