Just for human readability, in your example, I would map the colorname in the original table and use that to look up the code. The semantic intention behind the relationship is likely to give a color name that is descriptive, and the exact hex code is an implementation detail. It'll be easier to modify the color palette by changing the hex codes if they're looked up by name.
I actually thought about it a little myself, but couldn't quite decide which solution I found better. I ended up setting the colourcode as the (effectively) FK, so that different products could be different shades, but still be described by the same colour (you can have multiple shades of blue, but only one hexcode.) In cases where a "human readable" name isn't present in the second table, then straight up presenting the colourcode might be better than misrepresenting the colour with a not-descript-enough name.
I think both approaches are OK, but subject to consideration depending on what is likely to change.
4
u/dakta Apr 07 '21
Just for human readability, in your example, I would map the colorname in the original table and use that to look up the code. The semantic intention behind the relationship is likely to give a color name that is descriptive, and the exact hex code is an implementation detail. It'll be easier to modify the color palette by changing the hex codes if they're looked up by name.