Fixed foreign key being a string and not an integer and modified query to comply with postgres.