Storing measurements for users in metric and english measurement systems
I am rebuilding an application that stores data for search and recovery divers. Previously, it was for a single team and we used the english measurement systems, however, now that the application is growing to multiple teams and locations users and teams will have the ability to view data in either english or metric system measurements. My question is, do i store all data in one, ie english feet, and then convert each time for metric? The user can change their view preferences at any time. This would mean if a user said the dive was 3m deep, I'd store 9.842519685 and just do the math each time.
[Rails 7.1, Postgresql app]
Thanks for the thoughts.
The math is fast to do, so that would be fine to convert each time.
You could also use a virtual generated column to do the calculation at the database level. See this lesson: https://gorails.com/episodes/virtual-generated-columns-with-activerecord