What is the best strategy for storing custom email alert requests?

Users can perform advanced searches (there are many possible parameters):

/search/?query=toto&topic=12&minimumPrice=0&maximumPrice=1000

I would like to save the search parameters (after /search/?) for email alerts.

I have 2 options:

  • Saving the raw query ( query=toto&topicId=12&minimumPrice=0&maximumPrice=1000) in a table with a structure of type id, parameters.
  • Saving a query in a structured table identifier, query, topicId, minimumPrice, maximumPrice, etc.

Each solution has its pros and cons. Of course, solution 2 is cleaner, but is it really worth the effort?

If you have already implemented such a solution and experienced its maintenance, what is the best solution?

The best solution should be the best for every dimension:

  • Rigidity
  • Fragility
  • Viscosity
+3
3

Daniel, , , . PHP, - db, , , ? , . , , ?

, 2 , . (, № 2) . , . ", , , ?"

, 2 .

+1

, : search_id, key, value . , , . .

, key , , . , .

+1

, , . PHP , .

1- / , .

Daniel's answer is a general solution, but if you think performance is a problem, you can make too many inserts on the database side for one search (one for each parameter). Too many inserts are a common source of performance issues.

You know your resources.

+1
source

Source: https://habr.com/ru/post/1752135/


All Articles