Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TheFriendlyHacker's avatar

How to store options/settings in the database

My application will allow users to create posts. Posts will have certain settings that the user will be able to customize (e.g. "allow comments", "allow likes", "show author name", etc).

Should each of these options be stored as a separate column in the "posts" table (e.g. have columns like "allow_comments", "allow_likes", etc), or is there a better way to handle this?

0 likes
2 replies
Cronix's avatar

That would be the simplest, since they're a 1:1 relationship to post.

Snapey's avatar

If you are unsure what you might need in the future, you could store the values in a post metadata model as key+value pairs

If you have a post_id column on that table also, you can easily pull 2,3,4,5 etc rows from the meta table that are related to the post

Please or to participate in this conversation.