but to compare all the entries in the database takes quite a long time.
not if you let the database do it for you..
this is why relational databases were designed... whoever wrote your database (probably mysql) spent many many many sleepless night trying to optimize how it compares all the entries in 7 tables...
you want to be able to do that on the SQL side, not the php side... there will be orders of magnitude difference...
the most expensive operation for a RDBMS is a table merge (for reasons i will not get into)
so perhaps you can collapse some of your 7 tables into fewer tables....
ask google to search for tutorials on putting databases into things called Noraml Forms 1st normal, 2nd normal, BCNF etc...
these give methods of minimizing table structure (or when you should make new tables)
to join more than 2 tables you often need to use more complex joins...
ask google for tutorials in inner and outer joins... they may be userfull to you...
basically your problem is solvable if you SQL skillz are l33+ enough... so work on studying up in that areas...