2

Well, in SQLLite there is not exist the possibility to delete on cascade, or I don't know how.

Imagine that I have two tables, Table A and Table B. The table B has the IDtableA field, because is a child, and imagine that I have the following situation:

1.- user A load record 1 from TableA and load it in the context. 2.- user A load all the child records from table B. 3.- user B add a new record to table B that is child of table A. 4.- user A save changes and delete record 1 and all the childs that he loaded in the first time, but not include the new child add by the user B.

So in SqlLite I don't have a model, neither realationships between tables, when user B add a new child, not check if the parent exists.

is it posible ensure reference integrity in Sqlite?

Thanks.

3
  • 1
    Your reputation was not found (404) but it found it to you by upvoting your question :) :) it is 411 now :) Commented Dec 16, 2012 at 10:15
  • this may be usefull sqlite.org/foreignkeys.html Commented Dec 16, 2012 at 10:19
  • thanks for all, the reputation and the link :) Commented Dec 16, 2012 at 12:09

1 Answer 1

3

SQLite supports foreign keys and "on delete cascade", but in the new versions.

You can see this article in official SQLite website:

sqlite.org/foreignkeys.html

The say:

This document describes the support for SQL foreign key constraints introduced in SQLite version 3.6.19.

Also, you have to explicitly enable foreign keys for every connection.

this question may help you: Enabling Foreign key constraints in SQLite

You can do it by changing the connection string and add:

foreign keys=true; 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.