Subject foreign key violation
Author flashjobs
Hello!

I have a database in FirebirdSS-1.0.3.972-0

table structure is following

CREATE TABLE BILLMASTER (
BILLNUMBER CHAR(11) DEFAULT 0 NOT NULL,
BILLTYPE CHAR(2) NOT NULL,
BILLAMOUNT NUMERIC(15,2) DEFAULT 0.00,
BILLCANCELLED CHAR(1) DEFAULT 'N',
BILLDATE DATE NOT NULL,
BILLDISCOUNT NUMERIC(15,2) DEFAULT 0.00,
PATIENTNAME CHAR(20),
USERNAME CHAR(6) NOT NULL,
MACHINEID CHAR(10) NOT NULL);

/* Primary keys definition */
ALTER TABLE BILLMASTER ADD CONSTRAINT DBPKBILLMASTER PRIMARY KEY
(BILLNUMBER, BILLTYPE);


CREATE TABLE BILLITEMDETAILS (
BILLITEMCODE CHAR(5) NOT NULL,
BILLNUMBER CHAR(11) NOT NULL,
BILLTYPE CHAR(2) NOT NULL,
DOCTORCODE CHAR(6),
ITEMDESCRIPTION CHAR(300),
TRANSFERED CHAR(1) DEFAULT 'N',
DOCTORFEE NUMERIC(15,2),
PRODUCTSERIALNUMBER SMALLINT DEFAULT 0 NOT NULL,
BILLITEMCOST NUMERIC(15,2) DEFAULT 0.00,
BILLITEMQUANTITY SMALLINT DEFAULT 1);

/* Primary keys definition */
ALTER TABLE BILLITEMDETAILS ADD CONSTRAINT DBPKBILLITEMDETAILS
PRIMARY KEY (BILLNUMBER, BILLTYPE, SLNO);

/* Foreign keys definition */
ALTER TABLE BILLITEMDETAILS ADD CONSTRAINT DBFKMASTERBILL FOREIGN KEY
(BILLNUMBER, BILLTYPE) REFERENCES BILLMASTER (BILLNUMBER, BILLTYPE);

when i tried to restore this database, i cannot restore, one foreign
key violation error is coming, but the database is working perfectly

i have identified that there is invalid data(ie. data not in
BILLMASTER) in foreign key column(BILLNUMBER, BILLTYPE) of
BILLITEMDETAILS.


How these problems are coming?

when i trying to restore the database only i can understand there is
a problem.



Regards
Manoj