foreign_keys.sql 2.33 KB
Newer Older
1 2 3 4 5 6
/*
    FOREIGN KEY constraints are listed in a separate file so that they could be optionally switched on or off.

    A nice surprise is that the syntax for defining them is the same for MySQL and PostgreSQL.
*/

7

8 9 10 11 12 13
ALTER TABLE worker                  ADD FOREIGN KEY (analysis_id)               REFERENCES analysis_base(analysis_id);
ALTER TABLE dataflow_rule           ADD FOREIGN KEY (from_analysis_id)          REFERENCES analysis_base(analysis_id);
ALTER TABLE analysis_ctrl_rule      ADD FOREIGN KEY (ctrled_analysis_id)        REFERENCES analysis_base(analysis_id);
ALTER TABLE job                     ADD FOREIGN KEY (analysis_id)               REFERENCES analysis_base(analysis_id);
ALTER TABLE analysis_stats          ADD FOREIGN KEY (analysis_id)               REFERENCES analysis_base(analysis_id);
ALTER TABLE analysis_stats_monitor  ADD FOREIGN KEY (analysis_id)               REFERENCES analysis_base(analysis_id);
14

15
ALTER TABLE job                     ADD FOREIGN KEY (worker_id)                 REFERENCES worker(worker_id);
16
ALTER TABLE log_message             ADD FOREIGN KEY (worker_id)                 REFERENCES worker(worker_id);
17
ALTER TABLE job_file                ADD FOREIGN KEY (worker_id)                 REFERENCES worker(worker_id);
18

19 20
ALTER TABLE job                     ADD FOREIGN KEY (prev_job_id)               REFERENCES job(job_id);
ALTER TABLE job                     ADD FOREIGN KEY (semaphored_job_id)         REFERENCES job(job_id);
21
ALTER TABLE log_message             ADD FOREIGN KEY (job_id)                    REFERENCES job(job_id);
22
ALTER TABLE job_file                ADD FOREIGN KEY (job_id)                    REFERENCES job(job_id);
23 24
ALTER TABLE accu                    ADD FOREIGN KEY (sending_job_id)            REFERENCES job(job_id);
ALTER TABLE accu                    ADD FOREIGN KEY (receiving_job_id)          REFERENCES job(job_id);
25

26 27
ALTER TABLE resource_description    ADD FOREIGN KEY (resource_class_id)         REFERENCES resource_class(resource_class_id);
ALTER TABLE analysis_base           ADD FOREIGN KEY (resource_class_id)         REFERENCES resource_class(resource_class_id);
28
ALTER TABLE worker                  ADD FOREIGN KEY (resource_class_id)         REFERENCES resource_class(resource_class_id);
29

30
ALTER TABLE dataflow_rule           ADD FOREIGN KEY (funnel_dataflow_rule_id)   REFERENCES dataflow_rule(dataflow_rule_id);