pears.DocumentTypeDepartment

Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.

Links Document Types to Departments. Types with no record are available for all Departments.

Column Type Null Default Comment
DocumentTypeDepartmentID char(20) NOT NULL
DocumentTypeID char(20) NULL
DepartmentID char(2) NULL
  • DocumentTypeDepartmentID
Constraint Columns References Delete/update action
DocumentType DocumentTypeID pears.DocumentType (DocumentTypeID) ON DELETE CASCADE
Department DepartmentID pears.Department (departmentid) ON DELETE CASCADE
  • No incoming foreign keys found.
  • No indexes found.
Name Timing Event
DocumentTypeDepartmentDelete after delete order 1
-- 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
  • database/tables/pears_documenttypedepartment.txt
  • Last modified: 2026/08/07 19:24
  • by 127.0.0.1