====== pears.PersonShiftPreference ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Columns ===== ^ Column ^ Type ^ Null ^ Default ^ Comment ^ | **PersonShiftPreferenceID** | char(20) | NOT NULL | | | | personid | char(20) | NOT NULL | | | | TempShiftTemplateID | char(20) | NULL | | | | companyid | char(20) | NULL | | | | WhenEntered | timestamp | NOT NULL | current timestamp | | | WhoEntered | char(20) | NULL | | | ===== Primary Key ===== * PersonShiftPreferenceID ===== Foreign Keys ===== ^ Constraint ^ Columns ^ References ^ Delete/update action ^ | Person | personid | [[database:tables:pears_person|pears.Person (personid)]] | NOT NULL; ON DELETE CASCADE | | TempShiftTemplate | TempShiftTemplateID | [[database:tables:pears_tempshifttemplate|pears.TempShiftTemplate (TempShiftTemplateID)]] | ON DELETE CASCADE | | Company | companyid | [[database:tables:pears_company|pears.Company (companyid)]] | ON DELETE CASCADE | ===== Referenced By ===== * No incoming foreign keys found. ===== Indexes ===== * No indexes found. ===== Triggers ===== ^ Name ^ Timing ^ Event ^ | PersonShiftPreference_Insert | before | insert order 1 | ===== Original SQL ===== -- IQX database structure split by table -- Source: IQXDatabaseStructure - with comments.sql -- Table: "pears"."PersonShiftPreference" -- Table comment: -- Statement count: 6 CREATE TABLE "pears"."PersonShiftPreference" ( "PersonShiftPreferenceID" char(20) NOT NULL ,"personid" char(20) NOT NULL ,"TempShiftTemplateID" char(20) NULL ,"companyid" char(20) NULL ,"WhenEntered" timestamp NOT NULL DEFAULT current timestamp ,"WhoEntered" char(20) NULL ,PRIMARY KEY ("PersonShiftPreferenceID" ASC) ) go ALTER TABLE "pears"."PersonShiftPreference" ADD NOT NULL FOREIGN KEY "Person" ("personid" ASC) REFERENCES "pears"."Person" ("personid") ON DELETE CASCADE go ALTER TABLE "pears"."PersonShiftPreference" ADD FOREIGN KEY "TempShiftTemplate" ("TempShiftTemplateID" ASC) REFERENCES "pears"."TempShiftTemplate" ("TempShiftTemplateID") ON DELETE CASCADE go ALTER TABLE "pears"."PersonShiftPreference" ADD FOREIGN KEY "Company" ("companyid" ASC) REFERENCES "pears"."Company" ("companyid") ON DELETE CASCADE go create trigger "PersonShiftPreference_Insert" before insert order 1 on "pears"."PersonShiftPreference" referencing new as "new_psp" for each row when("new_psp"."whoentered" is null) begin set "new_psp"."whoentered" = "userstaffid" exception when others then set "new_psp"."whoentered" = null end go COMMENT TO PRESERVE FORMAT ON TRIGGER "pears"."PersonShiftPreference"."PersonShiftPreference_Insert" IS {create trigger PersonShiftPreference_Insert before insert order 1 on pears.PersonShiftPreference referencing new as new_psp for each row when(new_psp.whoentered is null) begin set new_psp.whoentered=userstaffid exception when others then set new_psp.whoentered=null end } go