1

I'm a student doing my final year. I am supposed to create a database for my project such that it stores multiple values under a Skills column. For one one user id there can be multiple values in the skills field.

What is the best way to proceed ? I'm supposed to create in Mysql.

5
  • 1
    See normalisation. Commented Oct 9, 2016 at 6:58
  • Thanks for the suggestion. I'll look it up. Commented Oct 9, 2016 at 6:59
  • I looked it up but it looked like it will take a lot of time. I'm on clock for my project. Is there any other way ? Commented Oct 9, 2016 at 7:03
  • It is the only sensible approach. Every other way will produce more problems later. Commented Oct 9, 2016 at 7:10
  • see the concept of junction/intersect and association tables like Here . If you are under the gun, then doing it with CSV values will just slow down the dev anyway. Commented Oct 9, 2016 at 7:13

1 Answer 1

1

The best practice would be to use two tables for this purpose.

UserTable:
Id    rest of the appropriate fields
1        ...........
2        ............

SkillSetTable:
id UserTable_id         skillName
1     1                   abcd
2     1                   pqrs
3     1                   hijk
4     1                   lmnop

Here you can use foreign key to point to UserTableid. That way you dont have to bother about number of skills

Sign up to request clarification or add additional context in comments.

5 Comments

A surrogate key serves no useful purpose here
Which one are you referring to as surrogate key ?
id in SkillSetTable is surrogate
it is a common behavior to have primary key in a table, here id is primary key.... although you may think the rest two column can combine to be a composite key, yet it is up to designer's perspective
Yes. It's surrogate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.