Pattern analyzer for databases