Adding reference category and joinging tables