Generalized database functions to work for both entries and cases tables.
Implemented barebones CaseWin.