Heat map algorithm and database code.