2 ms·
> What else can you do? Make a table that has every configuration value as a separate column and populate it with only a single row? If the values are singleto
by bastawhiz 8mo ago
> What else can you do? Make a table that has every configuration value as a separate column and populate it with only a single row?
If the values are singletons, what you're describing is the most efficient. What the author is describing is a surprisingly common anti-pattern where someone has a table with three columns: entity id, property name, property value. Almost like a graph database. Fetching data for one entity (normally one row in a properly built db) is fine, but fetching the data for multiple entities is instantly a mess.
It's worth noting, though, that unless the configuration values are all the same type, you lose type safety with just one column for values. "I'll parse the data as JSON" means your service will fail hard at runtime if someone changes the configuration and uses invalid data.
- supriyo-biswas 8mo agoPersonally I’d pass all my JSON-y stuff through Pydantic or similar which would take care of these concerns.
- bastawhiz 8mo agoIt wouldn't. If you load configuration and it's the wrong type, now Pydantic is throwing an error. You can't run code if the config is invalid no matter what tools you use: failing validation is still an error.