On Tue, 27 Sep 2011 14:58:06 +0400, Madhan Kumar <askmad...@gmail.com> wrote:
>Hello.. > In sqlite (version 3.7.7.1), I created two tables with foreign keys >as shown below > >CREATE TABLE [*Employee*] ( > [*EmpId*] INT NOT NULL, > [EmpName] VARCHAR2(50)); > >CREATE TABLE [*Department*] ( > [DeptID] INTEGER NOT NULL, > [DeptName] VARCHAR2(20), > [*EmpID*] INTEGER NOT NULL CONSTRAINT [FK_EMP_Dept] REFERENCES >[Employee]([*EmpId*])); > >Using sqlite Expert Tool, >I inserted a row in *Employee* Table - Success >when i want to delete the same row from Employee table - gives error >"foreign key mismatch". > >When i try to insert a row in *Department* Table, gives error "foreign key >mismatch". > >I tried executing PRAGMA foreign_keys = ON >and it returns "1" > >But still i am getting errors. Pls assist me to fix this issue. >Thanks in advance. I think you have the reference the wrong way around. Employee should reference Department, the relation is n:1. The way you have it now, Department references employee, which means a department can only have one employee. -- ( Kees Nuyt ) c[_] _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users