Refactored the database scheme so it works.