added database support. added pattern categories to database