Sample Header Ad - 728x90

How to design a database for search history with multiple facets?

3 votes
2 answers
309 views
I want to show users a history of their searches, which can often be complicated: - **any** of these terms: [a,b,c] - **all** of these terms: [d,e,f] - **not** these colors: [h,i,j] Since these searches are done through a UI (not a search input where they would type "a OR b etc...") I assume I would need to store each value in a table. Would it be overkill to create a table for each facet ("search_terms", "search_colors", etc)? or is there a simpler way?
| search_id |   term(_id)  | operator(enum)|
|:---------:|:------------:|:-------------:|
| 1         | blue         |     any       |
| 1         | green        |     any       |
| 1         | red          |     any       |
| 1         | musthave     |     all       |
| 1         | exclude_me   |     not       |
| 1         | exclude_also |     not       |
Some other considerations are: * The web-URL can change over time, so I don't want to store that as an easy way out. * The index/3rd party service I'm searching could change, so I similarly can't save the query I make. (The terms themselves can be its own table with a reference instead).
Asked by d-_-b (131 rep)
Jun 3, 2019, 10:20 PM
Last activity: Apr 29, 2025, 09:09 PM