Sort locale in database

* Added constraint for columns :locale && reference_table_id
* Fixes #237