This works as expected for me.  What version are you using? Did you set the
pragma each time?
 What do you mean by ".edmx"

John G


% sqlite3 test.db
SQLite version 3.7.7 2011-06-25 16:35:41

pragma foreign_keys=1;

CREATE TABLE Lesson (
   id INTEGER PRIMARY KEY AUTOINCREMENT,
   title TEXT NOT NULL);

CREATE TABLE Page (
   lesson_id INTEGER NOT NULL,
   id INTEGER PRIMARY KEY AUTOINCREMENT,
   title TEXT NOT NULL,
      FOREIGN KEY(lesson_id) REFERENCES Lesson(id));

insert into Lesson (title) values ('Abc');
insert into Lesson (title) values ('Def');
insert into Page (lesson_id, title)  values (1,'xxxxxxx');
insert into page (lesson_id, title)  values (2,'yyyyyyy');         <<<
lower case works fine
insert into Page (lesson_id, title)  values (3,'zzzzzzz');
Error: foreign key constraint failed                     <<<<<<<<<<<<<
error as expected


CREATE TABLE Lesson2 (
   id INTEGER PRIMARY KEY AUTOINCREMENT,
   title TEXT NOT NULL);

CREATE TABLE Page2 (
    lesson_id INTEGER NOT NULL,
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    title TEXT NOT NULL,
       FOREIGN KEY(lesson_id) REFERENCES lesson2(id));

insert into Lesson2 (title) values ('Abc');
insert into lesson2 (title) values ('Def');                  <<< lower case
works fine
insert into Page2 (lesson_id, title)  values (1,'xxxxxxx');
insert into page2 (lesson_id, title)  values (2,'yyyyyyy');
insert into Page2 (lesson_id, title)  values (3,'zzzzzzz');
Error: foreign key constraint failed                    <<<<<<<<<<<<< error
as expected so the releationship must be there


On 8 June 2012 18:55, Ludovic VP <ludovi...@hotmail.com> wrote:

>
> Hello,
> I was having a hard time understanding why a one-to-many relationship
> wasn't included in the .edmx of an Sqlite database, until I figured the
> issue is with the letter case of the referenced table in the foreign key
> definition. The following works ok:
> CREATE TABLE Lesson (    id INTEGER PRIMARY KEY AUTOINCREMENT,    title
> TEXT NOT NULL);
> CREATE TABLE Page (    lesson_id INTEGER NOT NULL,    id INTEGER PRIMARY
> KEY AUTOINCREMENT,    title TEXT NOT NULL,    FOREIGN KEY(lesson_id)
> REFERENCES Lesson(id));
> while with the following, the relationship is not added:
> CREATE TABLE Lesson (    id INTEGER PRIMARY KEY AUTOINCREMENT,    title
> TEXT NOT NULL);
> CREATE TABLE Page (    lesson_id INTEGER NOT NULL,    id INTEGER PRIMARY
> KEY AUTOINCREMENT,    title TEXT NOT NULL,    FOREIGN KEY(lesson_id)
> REFERENCES lesson(id));
> I'm guessing it's not a huge deal, but I thought I'd put it out there
> since it may be simple to fix.
> Sincerely,
> Ludovic Vaugeois-Pepin
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to