I think it is really unique for TaskId. So could you solve up my script ?
Here some error :
Inserting CR_job DATA
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
*
ERROR at line 1:
ORA-02291: integrity constraint (160767CI.CR_EMPLOYEEFK) violated - parent key
not found
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
*
ERROR at line 1:
ORA-02291: integrity constraint (160767CI.CR_EMPLOYEEFK) violated - parent key
not found
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
*
ERROR at line 1:
ORA-02291: integrity constraint (160767CI.CR_EMPLOYEEFK) violated - parent key
not found
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
*
ERROR at line 1:
ORA-02291: integrity constraint (160767CI.CR_EMPLOYEEFK) violated - parent key
not found
1 row created.
1 row created.
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
*
ERROR at line 1:
ORA-02291: integrity constraint (160767CI.CR_EMPLOYEEFK) violated - parent key
not found
1 row created.
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
*
ERROR at line 1:
ORA-02291: integrity constraint (160767CI.CR_EMPLOYEEFK) violated - parent key
not found
Commit complete.
Anyway, Sorry for my bad English. So help me Thanks :)
What I have tried:
PROMPT Creating CR_task Table
create table CR_task
(
TaskId char(4),
TaskName varchar(25) NOT NULL,
GivenDate date NOT NULL,
StartDate date,
EndDate date,
MaxHours number(3,1) DEFAULT (20.0),
Constraint CR_taskPK PRIMARY KEY (TaskId)
);
-- Spooling Prompts: CR_job table
PROMPT Creating CR_job Table
create table CR_job
(
TaskId char(4) NOT NULL,
EmpId char(2) NOT NULL,
HoursSpent number(3,1) DEFAULT (20.0),
Constraint CR_jobPK PRIMARY KEY (TaskId, EmpId),
Constraint CR_taskFK FOREIGN KEY (TaskId) REFERENCES CR_task (TaskId),
Constraint CR_employeeFK FOREIGN KEY (EmpId) REFERENCES CR_employee (EmpId)
);
PROMPT Inserting CR_task DATA
INSERT INTO CR_task (TaskId, TaskName, GivenDate, StartDate, EndDate, MaxHours)
VALUES (1234, 'OS upgrade', '1-Feb-2016', '3-Feb-2016', '10-Feb-2016', '10');
INSERT INTO CR_task (TaskId, TaskName, GivenDate, StartDate, EndDate, MaxHours)
VALUES (1235, 'Memory upgrade', '20-Feb-2016', '20-Feb-2016', '20-Feb-2016', '6');
INSERT INTO CR_task (TaskId, TaskName, GivenDate, StartDate, EndDate, MaxHours)
VALUES (1236, 'Fault Analysis', '4-Mar-2016', '5-Mar-2016', '7-Mar-2016', '20');
INSERT INTO CR_task (TaskId, TaskName, GivenDate, StartDate, EndDate, MaxHours)
VALUES (1237, 'Remove Virus', '15-Mar-2016', '16-Mar-2016', '20-Mar-2016', '40');
INSERT INTO CR_task (TaskId, TaskName, GivenDate, StartDate, EndDate, MaxHours)
VALUES (1238, 'Printer repair', '8-Apr-2016', '10-Apr-2016', '', '20');
INSERT INTO CR_task (TaskId, TaskName, GivenDate, StartDate, EndDate, MaxHours)
VALUES (1239, 'Cartridge replacement', '15-Apr-2016', '', '', '10');
PROMPT Inserting CR_job DATA
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1234, '01', '2');
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1235, '08', '4');
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1234, '07', '4');
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1234, '09', '3');
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1234, '10', '3');
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1236, '12', '1');
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1237, '01', '4');
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1238, '12', '2');
INSERT INTO CR_job (TaskId, EmpId, HoursSpent)
VALUES (1238, '04', '6');