TABLES alert_codes ( alert_type_cd varchar(5) NOT NULL, alert_description varchar(50), CONSTRAINT alerts_pk PRIMARY KEY (alert_type_cd) ); customers ( cust_id serial NOT NULL, cust_name varchar(30), CONSTRAINT customers_pk PRIMARY KEY(cust_id) ); locations ( cust_id bigint NOT NULL, location_id serial NOT NULL, location_desc varchar(50) NOT NULL, location_city varchar(40) NOT NULL, CONSTRAINT locations_pk PRIMARY KEY (cust_id, location_id) ); equipment ( cust_id bigint NOT NULL, equipment_id varchar(20) NOT NULL, equipment_desc varchar(50), CONSTRAINT equipment_pk PRIMARY KEY (cust_id, equipment_id), CONSTRAINT fk_equip_cust FOREIGN KEY (cust_id) REFERENCES customers(cust_id), CONSTRAINT fk_equip_loc FOREIGN KEY (location_id) REFERENCES locations(location_id) ); alerts (alert_id serial NOT NULL, cust_id bigint NOT NULL, location_id bigint NOT NULL, equipment_id varchar(20) NOT NULL, alert_type_cd varchar(5) NOT NULL, alert_time timestamp NOT NULL, CONSTRAINT alerts_pk PRIMARY KEY (alert_id), CONSTRAINT fk_alerts_cust FOREIGN KEY (cust_id) REFERENCES customers(cust_id), CONSTRAINT fk_equip_cust FOREIGN KEY (cust_id) REFERENCES customers(cust_id), CONSTRAINT fk_equip_loc FOREIGN KEY (location_id) REFERENCES locations(location_id), CONSTRAINT fk_equip FOREIGN KEY (equipment_id) REFERENCES equipment(equipment_id) ); schedule ( cust_id bigint NOT NULL, equipment_id varchar(20) NOT NULL, activedays varchar(5) NOT NULL, -- AD = all days, WD = mon-fri, Mn,Tu,Wd,Th,Fr active_start timestamp NOT NULL, active_end timestamp NOT NULL, CONSTRAINT fk_sched_cust FOREIGN KEY (cust_id) REFERENCES customers(cust_id), CONSTRAINT fk_equip FOREIGN KEY (equipment_id) REFERENCES equipment(equipment_id) ); holidays ( cust_id bigint NOT NULL, location_id bigint NOT NULL, holiday date NOT NULL, CONSTRAINT holiday_pk PRIMARY KEY (cust_id, location_id, holiday) );