A database server receives an incoming query and converts the query into
its canonical form. The database server compares the canonical incoming
query with stored template queries. If the incoming query matches one of
the stored template queries, then the query is legitimate and the query
is executed on the database. If the canonical incoming query does not
match one of the stored template queries, then the database server
determines whether the incoming query is malicious or anomalous. The
database server identifies tokens in the incoming query that are not
present in a similar template query. If the tokens have meaning in the
language utilized to express the query, the database server declares the
query malicious. Otherwise, the database server declares the query
anomalous.