I'm building a web service where I need to show different products/lists to different users based on their profiles/preferences. For example:

  • John, 24/M, single: Show list A and D;
  • Kyle, 48/M, married: Show list B and C;
  • Jennifer, 22/F, single: Show list C and F;

This is the first time I need to build something like this and I'm kind of lost, since I didn't found anything about this, or at least don't know the correct term of such a feature.

I'm using PHP and MySql on the backend, so for this I was thinking about using tables to create the relationship between users and the lists, for example:

enter image description here

Considering the database structure above, I'll have a main category table, where I can create multiple type of categories, and then associate each user to some categories. The same applies to the product list. After that, I would select, for example, the list with most categories shared between the list and the user.

It's still all theorical, since I don't know exactly if this is the best approach to this situation. Is there a better technique to achieve this result? As long as I can still use PHP and Mysql I can change to any other method. I just want to get the expected result the best possible way.

  • I don't seem to be able to make sense of this: "the list with most categories shared between the list and the user". Also where are the products? Jun 24, 2017 at 3:07
  • This topic, called "Market segmentation," is huge right now. Lots of ways to do it. Maybe start here for some ideas.
    – John Wu
    Jun 24, 2017 at 4:20
  • @TulainsCórdova I expressed myself wrong. I meant to say "the list with most common categories between users and lists". E.g.: User A and List C has 4 categories in common, but User A and list D has 7 categories in common, so I'll show list D instead of C. Also the products follow the same logic, a table of products (id, name, value, etc.) and a table to create relationship between lists and products. Jun 24, 2017 at 11:33

1 Answer 1


The type of feature you're looking for

This kind of feature is about personalization. There are several approaches to it:

  • explicit personalization, when user selects himself the list he wants to subscribe
  • rule based personalization, when some well defined rules define the lists to be presented
  • dynamic personalization, when algorithms define the lists to be presented or even build the list for each user based on some recommender system, or profiling or learning algorithms.

From your explantations, I understand that the lists are predefined, and you're in the context of a rule based personalization.

How to implement it

Your DB scheme allows to map a user to one or several categories and each category to one or several list. This is very flexible. It's practical if you have many lists for each category, if you have some marketing manager who maintains the lists to be presented to each category, and more generally, if you have more behavior and rules behind the categories than just the lists.

But it requires to manage the categories. If this is a burden, you could well flatten the scheme an have a simple n to n association table relating users with lists.

Another point to consider is the rules. If the categories or the lists are fixed, you could do some hard coding. The disadvantage is that every time new ones are added, you need to update your code. So an interesting alternative could be to have some kind of configurable rules, which allow to define and combine conditions on the properties of your user to determine the category. You could then apply these rules whenever the user account is updated.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.