Multiple "categories" to an item?

Good day everyone,

Iโ€™m creating an app where I have a โ€œItemsโ€ table and a โ€œCategoriesโ€ table.

Originally, I had a column โ€œitemCategoryโ€ within the Items table, so I could filter the items by that category. (e.g: โ€œfruitsโ€, โ€œvegetablesโ€, โ€œmeatโ€, โ€œfrozenโ€, โ€œjuicesโ€)

But now, I would like to be able to set several categories to a single item. This resembles the concept of adding โ€œtagsโ€ to the items.

The idea is that later I would be able to filter easily all items that meet a set of selected โ€œcategoriesโ€, so as an example, I could then filter all the โ€œfrozen fruitsโ€ by selecting the โ€œfruitsโ€ and the โ€œfrozenโ€ categories.

Also ideally it would be possible for the user to add more โ€œcategoriesโ€ when creating or editing an item.

Iโ€™ve seen the column tupe โ€œEnumListโ€, but Iโ€™m not sure if that will be the best solution for later being able to filter easily by one or multiple โ€œcategoriesโ€ (โ€œfrozen fruitsโ€ or โ€œfrozen vegetablesโ€)

1 2 197
2 REPLIES 2

Steve
Platinum 4
Platinum 4

Not sure what the question is.

There is no โ€œbestโ€ way. EnumList or a separate table both work. EnumList is easier to implement quickly, but may have drawbacks later depending on how your app behaves.

Based entirely on what youโ€™ve said in this post, my gut says EnumList.

Thank you Steve,

Indeed, it seems that EnumList will do the work nicely.

Top Labels in this Space