Show pageOld revisionsBacklinksExport to PDFFold/unfold allBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== pears.DocumentTypeDepartment ====== <WRAP center round info> Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. </WRAP> ===== Description ===== Links Document Types to Departments. Types with no record are available for all Departments. ===== Columns ===== ^ Column ^ Type ^ Null ^ Default ^ Comment ^ | **DocumentTypeDepartmentID** | char(20) | NOT NULL | | | | DocumentTypeID | char(20) | NULL | | | | DepartmentID | char(2) | NULL | | | ===== Primary Key ===== * DocumentTypeDepartmentID ===== Foreign Keys ===== ^ Constraint ^ Columns ^ References ^ Delete/update action ^ | DocumentType | DocumentTypeID | [[database:tables:pears_documenttype|pears.DocumentType (DocumentTypeID)]] | ON DELETE CASCADE | | Department | DepartmentID | [[database:tables:pears_department|pears.Department (departmentid)]] | ON DELETE CASCADE | ===== Referenced By ===== * No incoming foreign keys found. ===== Indexes ===== * No indexes found. ===== Triggers ===== ^ Name ^ Timing ^ Event ^ | DocumentTypeDepartmentDelete | after | delete order 1 | ===== Original SQL ===== <code sql> -- IQX database structure split by table -- Source: IQXDatabaseStructure - with comments.sql -- Table: "pears"."DocumentTypeDepartment" -- Table comment: Links Document Types to Departments. Types with no record are available for all Departments. -- Statement count: 6 CREATE TABLE "pears"."DocumentTypeDepartment" ( "DocumentTypeDepartmentID" char(20) NOT NULL ,"DocumentTypeID" char(20) NULL ,"DepartmentID" char(2) NULL ,PRIMARY KEY ("DocumentTypeDepartmentID" ASC) ) go COMMENT ON TABLE "pears"."DocumentTypeDepartment" IS 'Links Document Types to Departments. Types with no record are available for all Departments.' go ALTER TABLE "pears"."DocumentTypeDepartment" ADD FOREIGN KEY "DocumentType" ("DocumentTypeID" ASC) REFERENCES "pears"."DocumentType" ("DocumentTypeID") ON DELETE CASCADE go ALTER TABLE "pears"."DocumentTypeDepartment" ADD FOREIGN KEY "Department" ("DepartmentID" ASC) REFERENCES "pears"."Department" ("departmentid") ON DELETE CASCADE go create trigger "DocumentTypeDepartmentDelete" after delete order 1 on "pears"."DocumentTypeDepartment" referencing old as "OldTable" for each row begin delete from "DocumentTag" where "DocumentTypeID" = "OldTable"."DocumentTypeID" and "TagLocation" = "string"('A',"OldTable"."DepartmentID") end go COMMENT TO PRESERVE FORMAT ON TRIGGER "pears"."DocumentTypeDepartment"."DocumentTypeDepartmentDelete" IS {create trigger DocumentTypeDepartmentDelete after delete order 1 on pears.DocumentTypeDepartment referencing old as OldTable for each row begin delete from DocumentTag where DocumentTypeID = OldTable.DocumentTypeID and TagLocation = string('A',OldTable.DepartmentID) end } go </code> database/tables/pears_documenttypedepartment.txt Last modified: 2026/08/07 19:24by 127.0.0.1