Best practice to manage dropdown data fetched from database.

What is best way to manage dropdown data from database?

1) create a table for each dropdown

or

2) 1 table for all dropdowns.

Also please consider relations between tables, for example Country, States and Cities.

And with consideration of scalability, like more dropdowns or more dropdown labels.

  Discussion posts and replies are publicly visible

Parents
  • I've always seen a mixture of both approaches in real-world projects.  Country and State lists are most commonly (AFAIK) kept in their own tables since there is often other, fairly unique metadata that is / might be included with each entry. 

    Then for other dropdown types, particularly things that are explicitly unique and relevant only to your application, there is often a single "reference values" table, where each entry has its own unique id, then either an ID pointing to a "reference types" table, or more lazily, just a text field with the reference type name (this is a lot easier to deal with but can be slightly less scalable in certain ways).  These often include things that might ever be applicable, like "IS_ACTIVE", and also i recommend including a column to sort by since sorting alphabetically and/or by Primary Key might sometimes not be sufficient.  I usually name this column like "ORDER_ID" but I've seen other names - it's up to you.

Reply
  • I've always seen a mixture of both approaches in real-world projects.  Country and State lists are most commonly (AFAIK) kept in their own tables since there is often other, fairly unique metadata that is / might be included with each entry. 

    Then for other dropdown types, particularly things that are explicitly unique and relevant only to your application, there is often a single "reference values" table, where each entry has its own unique id, then either an ID pointing to a "reference types" table, or more lazily, just a text field with the reference type name (this is a lot easier to deal with but can be slightly less scalable in certain ways).  These often include things that might ever be applicable, like "IS_ACTIVE", and also i recommend including a column to sort by since sorting alphabetically and/or by Primary Key might sometimes not be sufficient.  I usually name this column like "ORDER_ID" but I've seen other names - it's up to you.

Children
No Data