This question is more theoretical. Let's say there is an entity in a one-to-many relationship. For example, a blog post can have zero or more tags. Those tags are stored in another table (that contains just 2 columns - the
post_id and the
tag). In a web app, the logic might be to fetch and show all the tags for each post when a post gets fetched. Is having a
has_tags boolean column to be used conditionally to know whether to query the post tags (saving a query) a bad micro-optimization practice?
Edit: I removed the statement about multivalued attribute tags because it was incorrect, misleading, and caused confusion. I am sorry for this. I did not plan to store multiple values in one column but in a separate table for the same concerns listed by the answers to this question.
Edit 2: I thought of using a
JOIN before asking this question but was afraid that it might lead to lower query performance than having a second query once the tables start to grow (probably because of creating a Cartesian product between the 2 tables before filtering, but I am not sure if it is implemented in such a way). That is why I posted this question.