Add missing foreign keys

Add missing foreign keys to job_metadata and schedule_metadata. Check
whether the foreign keys are existing. If not, then add.
Merge pull request #295 from amalaba/add_fk

Add missing foreign keys