

Ask HN: How to tell whether a query is a subset of another - n2n3
http://home.wangjianshuo.com/cn/20100505_ccceeieeaece.htm
Subject 
Please write an algorithm to determine if a query expression is a subset of another.<p>a little bit more explaining:<p>Take the SQL statement, for example, if the query A is 
age&#62; 21 
Query B is 
age&#62; 20<p>We know that the result of A is a subset of that of B. Those who meet the condition A will also  satisfy B. I need an algorithm that given any two expressions will tell this relationship.<p>code example:
if ($ queryA-&#62; isSubSet ($ queryB)) (echo ("A is subset of B");)<p>For simplicity, consider only simple AND, OR logical operations, greater than, equal to, less than comparisons.<p>This is one situation our less than 10 people technical team typically encountered . For example: to cope with more searches querying huge data that distributed in multiple cities on multiple servers. System administrators can use the data frequency and other patterns to set up several different databases (MySQL's, and Solr's). Thus, when a new item arrived, we can decide, which db to put it.<p>Then when a given query is a subset of another corresponding to a previously configured db, we can just check that one. This allows us to easily configure dozens of data sets, without changing a single line of code.
======
n2n3
translated to English by Google with some revision

Subject: Please write an algorithm to determine if a query expression is a
subset of another.

a little bit more explaining:

Take the SQL statement, for example, if the query A is age> 21 & Query B is
age> 20

We know that, the result of A is a subset of that of B. Those who meet the
condition A will also satisfy B. I need an algorithm that given any two
expressions will tell this relationship.

code example: if ($ queryA-> isSubSet ($ queryB)) (echo ("A is subset of B");)

For simplicity, consider only simple AND, OR logical operations, greater than,
equal to, less than comparisons.

This is one situation our less than 10 people technical team typically
encountered . For example: to cope with more search querying on huge data that
distributed on dozens of servers in multiple cities. System administrators can
use the data frequency and other patterns to set up several different
databases (MySQL's, and Solr's). Thus, when a new item arrived, we can decide,
which db to put it.

And when a given query is a subset of another corresponding to a previously
configured db, we can just check that one. This allows us to easily configure
dozens of data sets, without changing a single line of code.

