2 ms·
> In MySQL, though, as you said, you have to come up with two tables (one for `user`, one for `skills`, make sure FK are in place, and then use joins for filter
by robertlagrant 4y ago
> In MySQL, though, as you said, you have to come up with two tables (one for `user`, one for `skills`, make sure FK are in place, and then use joins for filtering... doesn't seem to me that this model fits better)
Their other option was an array-typed column. As per the article, Postgres' JSONB column type will give you that, as one example.
But the skills table - and many to many linking table - shines as soon as you want to treat skills as first-class concepts in some way, e.g. "only let people pick from this list of skills the skills administrator has approved" or "count how many people have the skill 'Java'". Then tables seem much more natural, as the skills table can model them as concepts in their own right.
- adammarples 4y agoThe data model fits better. The data is relational and fits neatly into a simple relational table of user_id, skill_id. I think perhaps you just don't perhaps like SQL syntax which is why a join feels weird to you, but what you've described is a 4 or 5 line sql query which anyone can understand. Additionally, you can now easily answer questions like. "How many skills does the average user have?" "Who has the most skills?" "What are the most popular skills?" etc, all likewise in trivially simple sql expressions.
- robertlagrant 4y agoI know (except I didn't know I didn't like SQL syntax). That's why I'm saying tables are a good idea.
- adammarples 4y agoAdditionally, FK constraints are a good thing, they mean that one of your users doesn't have the "Python" skill while another one has the "Pytthon" skill. You need this - and with SQL it's extremely easy to implement.
- robertlagrant 4y agoAre you replying to the comment you mean to be replying to? :)
- adammarples 4y agoYes, the one in which you considered FK constraints to be a waste of time
- robertlagrant 4y agoCan you quote where I said that?