Storing an array in a Retool DB and displaying as 'Tags'

I'm struggling with the correct format to store an array in the Retool DB which can then be used to populate a 'Tags' column in a table.

The purpose is to store colours associated with a design, each colour has an 'id', 'name' and 'hex' associated to it.

Each design could have multiple colours associated with it.

So for instance, a design with red and blue associated would appear as follows in a table...


The 'name' would be displayed in the tag and the 'hex' would define the tag colour.

Any suggestions are much appreciated!

Generally speaking you shouldn't be storing an array in a database. There should be something like a 'design_colours' table that stores a row per color per design using a foreign key. Then you'd consolidate those rows into objects that contain an array of colors after you've fetched the data from the DB, such as:

id: 1,
design_title: 'df',
colours: ['Blue']
id: 2,
design_title: 'Demo',
colours: ['Blue','Red']

If you're not going to be editing or otherwise joining on the values, though, you can do it by storing them as comma separated values in a string ('Blue,Red') and then using item.split(',') in the mapped_value field in the column to create the array that Retool expects.


As it's just for display purposes I think splitting the string will do just fine for now.

Always the simplest solutions you overlook!