db foreign key reference bugfix