ALTER TABLE PIRAndSMRWorks
	ADD FOREIGN KEY (ApplicationID)
	REFERENCES TCApplications(TCApplicationID)
	ON DELETE CASCADE
        ON UPDATE CASCADE

ALTER TABLE PIRAndSMRWorks ADD FOREIGN KEY(ProjectExecutorID) REFERENCES Персонал(Код_работника)
ALTER TABLE PIRAndSMRWorks ADD FOREIGN KEY(ProjectTabEditorID) REFERENCES Персонал(Код_работника)		
ALTER TABLE PIRAndSMRWorks ADD FOREIGN KEY(ProjectRefuzedID)REFERENCES TCActProjectRefuzed  (TCActProjectRefuzedID)
ALTER TABLE PIRAndSMRWorks ADD FOREIGN KEY(ProjectAttachID) REFERENCES StoreDocuments(DocumentID)	 
ALTER TABLE PIRAndSMRWorks ADD FOREIGN KEY(ProjectTechWatchActAttachID) REFERENCES StoreDocuments(DocumentID)	
ALTER TABLE PIRAndSMRWorks ADD FOREIGN KEY(ProjectApplicantOrganizationID) REFERENCES LegalEntities(LegalEntityID)
ALTER TABLE PIRAndSMRWorks ADD FOREIGN KEY(ProjectApplicantTabEditorID) REFERENCES Персонал(Код_работника)
ALTER TABLE PIRAndSMRWorks ADD FOREIGN KEY(SMRLegalEntityID) REFERENCES LegalEntities(LegalEntityID)
ALTER TABLE PIRAndSMRWorks ADD FOREIGN KEY(SMRExecutorID) REFERENCES Персонал(Код_работника)
ALTER TABLE PIRAndSMRWorks ADD FOREIGN KEY(SMRTabEditorID) REFERENCES Персонал(Код_работника)
