T
T
Think With Your Head2016-09-01 19:36:38
MySQL
Think With Your Head, 2016-09-01 19:36:38

Which is better: a list of foreign keys in an entity or a pivot table?

Hello.
I am developing a simple project for a resume base.
There are user entities and skills. Each user can have up to about 100 skills. Users can be tens, hundreds of thousands.
What is the best way to do it - a pivot table or just list the skill IDs in the essence of the user, and then parse this "string"?
I'm scratching my head: the
pivot table can turn out to be very cumbersome, the records in it will grow by leaps and bounds, because each user will have at least 3 skills, and a maximum of about 100
in general, in the second case it will be problematic to search for users by skill: you will have to check each record about the user by parsing column "skills" for the presence of a given in the search
, I may not know something, perhaps there is a third option
I will be very grateful
I use doctrine - mysql. maybe there is some solution on another stack?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jaxel, 2016-09-01
@thinkbrain2

If you do it via the id enum, how are you going to search for users with a particular skill?
You have a standard many-to-many relationship. You need to do it through the link table. All the problems you describe for the link table are far-fetched. This table will not be cumbersome. There are two columns, the table will easily digest many millions of records. And selections will be thousands of times faster than parsing by column.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question