Subject Error restoring - foreign key reference does not exist
Author Bob Murdoch
I am using FB version 2.5.2 (64bit) on a Windows 2008 server.



When trying to restore a database, I am receiving the following error
message in the restore log:



gbak: activating and creating deferred index
FK_USER_DASHBOARD_ELEMENT_TO_US

gbak:cannot commit index FK_USER_DASHBOARD_ELEMENT_TO_US

gbak: ERROR:violation of FOREIGN KEY constraint
"FK_USER_DASHBOARD_ELEMENT_TO_US" on table "USER_DASHBOARD_ELEMENT"

gbak: ERROR: Foreign key reference target does not exist



CREATE TABLE USER_DASHBOARD (

USER_DASHBOARD_ID INTEGER NOT NULL,

USER_ID INTEGER NOT NULL,

NAME VARCHAR(40),

INS_DATE DATE,

GRID_ROW_COUNT INTEGER,

GRID_COL_COUNT INTEGER

);



CREATE TABLE USER_DASHBOARD_ELEMENT (

USER_DASHBOARD_ELEMENT_ID INTEGER NOT NULL,

USER_DASHBOARD_ID INTEGER NOT NULL,

DASHBOARD_ELEMENT_ID INTEGER NOT NULL,

DISPLAY_ROW INTEGER,

DISPLAY_COL INTEGER,

INS_DATE DATE,

REMOTE_INSTALLATION_ID INTEGER

);



ALTER TABLE USER_DASHBOARD_ELEMENT

ADD CONSTRAINT FK_USER_DASHBOARD_ELEMENT_TO_US FOREIGN KEY
(USER_DASHBOARD_ID)

REFERENCES USER_DASHBOARD (USER_DASHBOARD_ID) ON DELETE CASCADE;





I have verified that there are no entries in USER_DASHBOARD_ELEMENT that do
not have a foreign key:



select

e.user_dashboard_element_id, count(u.user_dashboard_id)

from

user_dashboard_element e

left join user_dashboard u on (u.user_dashboard_id = e.user_dashboard_id)

group by

1

having

count(u.user_dashboard_id) = 0





I have also verified that the index that supports this foreign key is in
fact active. I'm not sure what the error message means in this case - is
there an error or not?



Thanks,



Bob M..





[Non-text portions of this message have been removed]