Re: [sqlite] database design question

2013-06-12 Thread James K. Lowden
On Wed, 12 Jun 2013 13:55:25 +0400 dd wrote: > I am trying minimize queries on Authors table. For every deletion of > record from Books, it needs to check in Authors table. One extra > query execution is there. I am trying minimize that. You might not be aware of what you

Re: [sqlite] database design question

2013-06-12 Thread dd
I got it. Thank you RSmith and Simon Slavin. On Wed, Jun 12, 2013 at 2:54 PM, Simon Slavin wrote: > > On 12 Jun 2013, at 11:14am, dd wrote: > > > Yes Simon. I am looking for it. ON DELETE RESTRICT. > > > > I got the answer. > > > > Should I enable

Re: [sqlite] database design question

2013-06-12 Thread Simon Slavin
On 12 Jun 2013, at 11:14am, dd wrote: > Yes Simon. I am looking for it. ON DELETE RESTRICT. > > I got the answer. > > Should I enable foreign key support to use on delete restrict?( > http://www.sqlite.org/foreignkeys.html) I think that that fits with your earlier

Re: [sqlite] database design question

2013-06-12 Thread RSmith
Foreign Key constraints are enabled or disabled for a connection to a database using the "PRAGMA foreign_keys = ON" SQL on the connection that should be doing the constraining. After that, only DBs that have tables with foreign key constraints in one or more Tables will be affected by the setting

Re: [sqlite] database design question

2013-06-12 Thread dd
Yes Simon. I am looking for it. ON DELETE RESTRICT. I got the answer. Should I enable foreign key support to use on delete restrict?( http://www.sqlite.org/foreignkeys.html) I have x databases without enabling foreign key support. Can I enable foreign key support for x+1 database only? On

Re: [sqlite] database design question

2013-06-12 Thread RSmith
Hi there, May I ask, if you have a one-to-one relation of Books vs. Authors and wish to maintain it as such, why do you not just have one table with both fields and appropriate indexes? Searches wouldn't really be much faster, but all this deletion maintenance would go right down to near

Re: [sqlite] database design question

2013-06-12 Thread Simon Slavin
On 12 Jun 2013, at 9:49am, dd wrote: >>> Book titles are not unique. > I agree. 2. Books : columns(BookId_primarykey, > Book_id_in_string_format_like_guid) I’m not sure why you would need a GUID. You can store 2. Books : columns(BookId_primarykey, Title)

Re: [sqlite] database design question

2013-06-12 Thread dd
Thanks for your response. It will delete from Author_Books when book deleted. I am trying minimize queries on Authors table. For every deletion of record from Books, it needs to check in Authors table. One extra query execution is there. I am trying minimize that. On Wed, Jun 12, 2013 at 1:00

Re: [sqlite] database design question

2013-06-12 Thread Clemens Ladisch
dd wrote: > my app need to delete author record from author table when author > doesn't have any books. How to handle this? (I can verify in author > table, whether this author belongs to any other book when book > deletion. You mean the Author_Books table. > If no, delete from author table.

Re: [sqlite] database design question

2013-06-12 Thread Clemens Ladisch
dd wrote: > I am working on sample database application. I want to store book names > and authors. > > 1. Authors: columns(AuthorId_primarykey, Name, SSN) > 2. Books : columns(BookId_primarykey, Title)//Title is unique Book titles are not unique. > 3. Author_Books:

[sqlite] database design question

2013-06-12 Thread dd
Hi All, I am working on sample database application. I want to store book names and authors. Tables: 1. Authors: columns(AuthorId_primarykey, Name, SSN) 2. Books : columns(BookId_primarykey, Title)//Title is unique 3. Author_Books: columns(AuthorId_primarykey, BookId_primarykey) Here,