Lets say I have a global dataset and I run queries over those data set. For example my dataset would be
- #id, #Name, #Employee, #Birthdate, #number_of_children
- 1, Nick, Nasa, 1982, 1
- 2, Jack, Exon, 1985, 5
- 3, Tom, ABCD, 1978, 0
And I can run queryies on those dataset. sample queries would be * #Query => #Result_ids * (Name starts with A) =>  * (Birthdate before 1983 and have children ) => 
I want to store those queries on a data structure and I want to be able to do set operations on those queries like intersection and union. So an example union operation would be.
(Birthdate before 1983) intersection (have children) => (Birthdate before 1983 and have children)
I also want to be able to findout if one query is subset or superset of another one. For example.
(Birthdate before 1983) is superset of (Birthdate before 1980) (Have 3 children) is subset of (Have more than 1 children)
(Name = Jack and born in 1980) is subset of (Born before 1990)
I will have a program that will have thousands of queries. And it will combine those queries to make more variety of queries. When I have a new query, I will compare it with existing queries to see if I have an exact query in store or have a superset.
Can anybody suggest me a data structure that is fast enough to store and operate on those data?