This is just a quick database design discussion. When you encounter a field in a database that can take on one of a set number of values, how do you handle storing them?
Let me give an example: A database that has a table for cars stores the condition the car is in. Say the options are: “New”, “Excellent”, “Good”, “Average”, and “Bad”.
The way I see it there are 3 options here in storing these conditions:
- Create a separate “condition” table with a relationship between that and the car table. This means you can associate more information with the condition.
- Store the condition in an enumerable type with the ecto enum library. Postgres handles the validation and such for you.
- Store the condition as a string and do all validation and such on the server side of things. This might be the simplest, but it’s a lot less flexible.
What do you all think is the best approach and why? Under what conditions would you choose one approach over another?






















