first actual database code, reworked tables