pears.DocumentTypeDepartment
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
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 | pears.DocumentType (DocumentTypeID) | ON DELETE CASCADE |
| Department | DepartmentID | 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
-- 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