37 lines
1003 B
SQL
37 lines
1003 B
SQL
DROP TABLE IF EXISTS mocha_relationships;
|
|
|
|
CREATE TABLE mocha_relationships
|
|
(
|
|
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
|
tenant_id INT,
|
|
source_inst_id INT,
|
|
relationship_inst_id INT,
|
|
destination_inst_id INT,
|
|
user_inst_id INT,
|
|
effective_date DATETIME,
|
|
remove_flag INT,
|
|
|
|
INDEX `rel_index_FI_1`
|
|
(tenant_id, source_inst_id, relationship_inst_id),
|
|
|
|
CONSTRAINT `rel_inst_id_FK_tenant`
|
|
FOREIGN KEY (`tenant_id`)
|
|
REFERENCES `mocha_tenants` (`id`),
|
|
|
|
CONSTRAINT `rel_inst_id_FK_src`
|
|
FOREIGN KEY (`source_inst_id`)
|
|
REFERENCES `mocha_instances` (`id`),
|
|
|
|
CONSTRAINT `rel_inst_id_FK_rel`
|
|
FOREIGN KEY (`relationship_inst_id`)
|
|
REFERENCES `mocha_instances` (`id`),
|
|
|
|
CONSTRAINT `rel_inst_id_FK_dst`
|
|
FOREIGN KEY (`destination_inst_id`)
|
|
REFERENCES `mocha_instances` (`id`),
|
|
|
|
CONSTRAINT `rel_inst_id_FK_usr`
|
|
FOREIGN KEY (`user_inst_id`)
|
|
REFERENCES `mocha_instances` (`id`)
|
|
);
|