Dear All,
I have tables designed as below, but i always get Caused by: java.sql.SQLException: Integrity constraint violation: SYS_FK_16 table: BOSS in statement [insert into COMPANY (WORKER_ID, WORKER_DEPAT_ID, BOSS_ID, BOSS_DEPAT_ID, COMPANY_ID) values (1, 2, 1, 11, 1)]
at org.hsqldb.Trace.getError(Unknown Source)
for insert record to table Company
Could any one give me some hints ?
CREATE TABLE WORKER (
depat_id int NOT NULL ,
worker_id int NOT NULL,
salary decimal(20,4) NOT NULL,
primary key (depat_id,worker_id)
)
CREATE TABLE BOSS (
depat_id int NOT NULL ,
boss_id int NOT NULL,
salary decimal(20,4) NOT NULL,
primary key (depat_id,boss_id)
)
CREATE TABLE COMPANY(
company_id int NOT NULL PRIMARY KEY,
boss_id int NOT NULL,
boss_depat_id int NOT NULL ,
worker_id int NOT NULL,
worker_depat_id int NOT NULL ,
foreign key (boss_id, boss_depat_id) references BOSS (boss_id,depat_id),
foreign key (worker_id, worker_depat_id) references WORKER (worker_id,depat_id)
)
I have tables designed as below, but i always get Caused by: java.sql.SQLException: Integrity constraint violation: SYS_FK_16 table: BOSS in statement [insert into COMPANY (WORKER_ID, WORKER_DEPAT_ID, BOSS_ID, BOSS_DEPAT_ID, COMPANY_ID) values (1, 2, 1, 11, 1)]
at org.hsqldb.Trace.getError(Unknown Source)
for insert record to table Company
Could any one give me some hints ?
CREATE TABLE WORKER (
depat_id int NOT NULL ,
worker_id int NOT NULL,
salary decimal(20,4) NOT NULL,
primary key (depat_id,worker_id)
)
CREATE TABLE BOSS (
depat_id int NOT NULL ,
boss_id int NOT NULL,
salary decimal(20,4) NOT NULL,
primary key (depat_id,boss_id)
)
CREATE TABLE COMPANY(
company_id int NOT NULL PRIMARY KEY,
boss_id int NOT NULL,
boss_depat_id int NOT NULL ,
worker_id int NOT NULL,
worker_depat_id int NOT NULL ,
foreign key (boss_id, boss_depat_id) references BOSS (boss_id,depat_id),
foreign key (worker_id, worker_depat_id) references WORKER (worker_id,depat_id)
)