DB refactor, foreign keys support for var_measure.