Enforce foreign key constraints in tokens

fixes #4