Best Data structure for implementation of dependent drop-downs

I want to implement dependent drop-down feature on a web page in my website containing the following drop-downs:

  1. User’s group name
  2. Group events (dependent drop-down)
  3. Locations (dependent drop-down)

Now, what I want is according to the selected option in the first drop-down that is group name (the other two will be disabled until it is selected), the list of events is displayed; only those values relevant to the selected group name should occur. Similarly, the values of locations should be in relevance to the group name and the event selected. Not only this, but I also want the design to be irrelevant of the level of dependencies or the current order (group name->events->locations). Even if I wish to add timings as another level of dependency, the design should incorporate it.

Now, in all the related questions to this problem tables are used to store data in databases like:

  • Best Data structure for dependent dropdown implementation
  • Two dependent drop-down lists with the values in two different
    tables
  • Saving data of dependent drop-down – Yii

However, I wish to consider the following alternatives:

  1. Trie: Since the order in which the attributes are selected is
    defined, we could use a trie to store all possible combinations of
    the list of values in each drop-down dependent on each other. Using
    prefix search, we could retrieve the values of the next drop-down,
    according to value selected in the previous one.
  2. Table: similar to one used in above, we can store it in database but
    then the number of levels of dependencies are not really fixed and
    can increase in future. How do I handle that? (Assuming I don’t want
    to modify the schema every time this happens)
  3. Graph: We could also store the possible combinations in a directed
    graph and based on the values selected we can display all the next
    adjacent nodes int he next dependent drop-down.

Which of these is a best approach, keeping in mind future extensibility or changes? Or any other suggestions for data structures are also welcomed. Please explain with proper design in detail considering complexity in mind.

You’re almost certainly overthinking this. Your quest for an ideal data structure is a solution in search of a problem.

Look carefully at the example you gave. All three of those dropdowns have a different data source, and they imply a relational structure. Just by looking at the names of your dropdowns, I know that you have three tables: Groups, Events and Locations, each having primary keys and foreign keys that associate the tables with each other.

Three tables in a relational database is the ideal data structure for your scenario.

If you need a data representation that can be used in a web page, create a ViewModel object, but in non-trivial applications, it’s often necessary to AJAX in the list for a particular dropdown, based on the selection provided by the user in the previous dropdown. The lists can be too large to embed in the actual web page.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật