====== pears.BoilerPlatedivision ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Description =====
Links BoilerPlate records with Divsions. Boiler Plates with no records are available to all.
===== Columns =====
^ Column ^ Type ^ Null ^ Default ^ Comment ^
| **BoilerPlateid** | char(20) | NOT NULL | | |
| **divisionid** | char(20) | NOT NULL | | |
===== Primary Key =====
* BoilerPlateid, divisionid
===== Foreign Keys =====
^ Constraint ^ Columns ^ References ^ Delete/update action ^
| BoilerPlate | BoilerPlateid | [[database:tables:pears_boilerplate|pears.BoilerPlate (BoilerPlateID)]] | NOT NULL; ON DELETE CASCADE |
| division | divisionid | [[database:tables:pears_division|pears.Division (divisionid)]] | NOT NULL; ON DELETE CASCADE |
===== Referenced By =====
* No incoming foreign keys found.
===== Indexes =====
* No indexes found.
===== Triggers =====
^ Name ^ Timing ^ Event ^
| BoilerPlateDivisionDeleteAudit | after | delete order 1 |
| BoilerPlateDivisionInsertAudit | after | insert order 1 |
===== Original SQL =====
-- IQX database structure split by table
-- Source: IQXDatabaseStructure - with comments.sql
-- Table: "pears"."BoilerPlatedivision"
-- Table comment: Links BoilerPlate records with Divsions. Boiler Plates with no records are available to all.
-- Statement count: 8
CREATE TABLE "pears"."BoilerPlatedivision" (
"BoilerPlateid" char(20) NOT NULL
,"divisionid" char(20) NOT NULL
,PRIMARY KEY ("BoilerPlateid" ASC,"divisionid" ASC)
)
go
COMMENT ON TABLE "pears"."BoilerPlatedivision" IS
'Links BoilerPlate records with Divsions. Boiler Plates with no records are available to all.'
go
ALTER TABLE "pears"."BoilerPlatedivision"
ADD NOT NULL FOREIGN KEY "BoilerPlate" ("BoilerPlateid" ASC)
REFERENCES "pears"."BoilerPlate" ("BoilerPlateID")
ON DELETE CASCADE
go
ALTER TABLE "pears"."BoilerPlatedivision"
ADD NOT NULL FOREIGN KEY "division" ("divisionid" ASC)
REFERENCES "pears"."Division" ("divisionid")
ON DELETE CASCADE
go
create trigger "BoilerPlateDivisionDeleteAudit" after delete order 1 on
"pears"."BoilerPlateDivision"
referencing old as "old_Plate"
for each row
begin
declare "DivName" char(30);
select "name" into "DivName" from "Division" where "divisionid" = "old_Plate"."divisionid";
call "AuditLog"('BOILERPLATEDIVISION',"old_Plate"."BoilerPlateID","string"('Removed Boiler Plate Division - ',"DivName"),"DivName",'')
end
go
COMMENT TO PRESERVE FORMAT ON TRIGGER "pears"."BoilerPlatedivision"."BoilerPlateDivisionDeleteAudit" IS
{create trigger BoilerPlateDivisionDeleteAudit
after delete order 1 on
BoilerPlateDivision
referencing old as old_Plate
for each row
begin
declare DivName char(30);
select name into DivName from Division where divisionid = old_Plate.divisionid;
call AuditLog('BOILERPLATEDIVISION',old_Plate.BoilerPlateID,string('Removed Boiler Plate Division - ',DivName),DivName,'');
end
}
go
create trigger "BoilerPlateDivisionInsertAudit" after insert order 1 on
"pears"."BoilerPlateDivision"
referencing new as "new_Plate"
for each row
begin
declare "DivName" char(30);
select "name" into "DivName" from "Division" where "divisionid" = "new_Plate"."divisionID";
call "AuditLog"('BOILERPLATEDIVISION',"new_Plate"."BoilerPlateID","string"('BOILERPLATEDIVISION New Division Added : ',"DivName"),'',"DivName")
end
go
COMMENT TO PRESERVE FORMAT ON TRIGGER "pears"."BoilerPlatedivision"."BoilerPlateDivisionInsertAudit" IS
{create trigger BoilerPlateDivisionInsertAudit
after insert order 1 on
BoilerPlateDivision
referencing new as new_Plate
for each row
begin
declare DivName char(30);
select name into DivName from Division where divisionid = new_Plate.divisionID;
call AuditLog('BOILERPLATEDIVISION',new_Plate.BoilerPlateID,string('BOILERPLATEDIVISION New Division Added : ',DivName),'',DivName)
end
}
go