Subject | Re: foreign key violation |
---|---|
Author | james_027 |
Post date | 2005-02-02T07:29:32Z |
Hi,
--- In firebird-support@yahoogroups.com, "flashjobs" <flashjobs@y...>
wrote:
one field for defining primary key? could you make it into one field
may be this will solve your problem.
James
--- In firebird-support@yahoogroups.com, "flashjobs" <flashjobs@y...>
wrote:
>Iam not an expert, but I am wondering why is it that you use more than
>
> 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
one field for defining primary key? could you make it into one field
may be this will solve your problem.
James