Skip to main content
vamsik0002
April 8, 2021
Question

Best practice to manage dropdown data fetched from database.

  • April 8, 2021
  • 5 replies
  • 0 views

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.

5 replies

mikes0011
Brainy
April 8, 2021

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.

April 8, 2021

Hi vamsik0002 ,

I would suggest to create separate tables with  foreign key relationships. And then you can use the selected option dropdown populate the following dropdown( cascading dropdowns ), pls refer the below link for https://docs.appian.com/suite/help/21.1/recipe-configure-cascading-dropdowns.html

 

Ex : Country is Parent table then State and then City table. For long Run its easy to maintain.

Country 

CountryId_pk  CountryName

1                Australia

2               USA

3              Singapore

State

stateid_pk  StateName    countryid_fk 

1               Texas            2

2               California      2

3             Melbourne      1

Cityd_pk  CityName    Stateid_fk

1               Houston           1

2              Austin                1

3             Los Angeles      2

4            SanJose            2

Note: Also You can maintain single table. But above logic helps you refer/reuse wherever you need only fields. 

Please let me know if this helps. Thanks

stefanhelzle0001
April 8, 2021

If this reference data is fairly simple and static, then putting it into a constant is also a viable option.