How to nest a list of items within a list of items?

Options

I want to have a user select a car manufacturer from a list of available options so that, when they choose their car manufacturer, it then brings up the available models for them to choose from.

I do not want users to store their vehicles as text fields, as this would make it harder to verify whether their insurance is valid or not.

Answers

  • arturosanz
    arturosanz Member ✭✭
    Options

    One way to do it is creating two tables, one for car manufacturers and one for car models. Then you establish a relationship between both tables by including a table reference field in the car models table which relates to the car manufacturers table.

    When you add the list of car models to the table, you "connect" them to their manufacturers through that relationship. Then you can easily query this table reference field for all models that belong to any manufacturer you want. The user will only have to choose from the subset of models your query returned back, and won't have to input any model name or any data already stored in the car models table.

    If you have too many records in your car models table you can also create an index by the table reference field to perform the query faster.

  • justin_88
    justin_88 Member
    Options

    Thank you for your insight. That's kinda what I thought I'd need to do, so it looks like I'm on the right track, at least.