Sorry for the non-descriptive title, I don't know how to explain what I'm trying to achieve succinctly.In most SQL use-cases, we have records in the database that have properties, and we are trying to retrieve records which match some conditions. For example, we may have for instance a table of products, where each product has a release date, a price and a category. We can then easily query for products released after a certain date, with a price below a certain value and belonging or not belonging to a specific category.What I am trying to achieve is essentially the reverse of this. I have a table of services with conditions, and each user has various properties. (think 'date of birth', 'has drivers license', etc...) I need to display a list of all services that a given user is eligible for.Another one of my requirements is that this needs to be possible for anonymous users, so the property values for the user won't be stored in a table anywhere, they will simply be provided as part of the user's request to my server.I'm struggling to think of what the best way to achieve this would be. At the moment I see two main possibilities:1. Build out a relational model for the conditions, and build long SQL queries based on user inputIn order for a user to be eligible for a service, they must fulfill at least one Condition Group. In order for a user to fulfill a Condition Group, they must fulfill all the Conditions within that group.Pros:Works with a well defined ERD and proper SQL queriesCons:Have to generate very complicated SQL queries with multiple joins, reduced flexibility for writing conditions2. Store conditions as a string. Build a condition parser and go through all services testing their condition against the user input.ProsFlexible and easier-to-write conditions, easier to developConsQueries have to take place in application-layer instead of database-layer, possibly bad performanceIm wondering if anyone has dealt with a similar problem in the past, and how they solved it. Maybe theres an option Im not considering? Im open to use a NoSQL solution if its a better fit for the problem, but my preference is to do this against a SQL database if practical.
SQL reverse filtering system
design;database;database design;search;filtering