Update database scheme

and refactor the classes to match the updated scheme.