I would be grateful for any advice anyone has:
How do you efficiently store gps (or any floating-point number) in a varchar field that can be indexed.
Background:
We are developing a content management system that can efficiently store files of any type together with a collection of metadata. This file / metadata is stored as follows:
file_table metadata_table ---------- -------------- file_id -> file_id (number) file_name metadata_id (number) file_location metadata_value (varchar) ...etc
I was asked to provide support for survey files (i.e. store gps coordinates as metadata). In addition, we would also like to support files with multiple geotags.
Now, as far as I can see, I have several options:
1) Keep latitude and longitude within the same metadata_value varchar (e.g. '52 .4343242, -1.32324 ').
How can I query this string? Is there anything clever that I can do with sql that allows me to query the "components" of a string? Can I save the coordinate as an xml string - will this help? How can this be effectively indexed?
2) Store latitude and longitude as separate lines in metadata_table.
This solution eliminates the problem of simplifying queries (due to complexity and cumbersomeness, especially when I will store several geo-tags for each file), however, I still encounter the indexing problem.
I can convert varchars to a floating point when prompted, however I'm not sure if this will ignore the index that I have on metadata_table.metadata_value and scan the tables instead.
3) Create special floating point fields to store gps data.
This is the least desirable option because it goes against the grain of the project to add database fields for specific metadata. Not all files will store gps data.
Any help or recommendation appreciated.