[sqlite] Insert rows into a foreign key table

2011-08-15 Thread David Westbury
For the two tables shown here, what sqlite INSERT statement would add a new Order for person Hansen? Is it possible to add a new order with one sql statement or does it require two statements? The only way I have found to add a new order is to first SELECT the P_Id for Hansen from the Persons

[sqlite] Is it okay to use SQLite + PHP for Library Software?

2011-08-15 Thread Raouf Athar
Hi, I have to develop a Library Management System using *PHP* for a medium sized college library. The library has about 5,000 members and 50,000 books. On an average, about 500 members will look for books and will be issued books on daily basis. *Kindly let me know if it is okay to use

Re: [sqlite] Insert rows into a foreign key table

2011-08-15 Thread Igor Tandetnik
David Westbury pe8...@yahoo.com wrote: For example, why won't an embedded select statement similar to the following work? INSERT INTO ORDERS (OrderNo, P_Id) values ( 12345, select P_Id from persons where LastName = 'Hansen') Because it's not valid SQL. Try this one: INSERT INTO ORDERS

Re: [sqlite] Insert rows into a foreign key table

2011-08-15 Thread Black, Michael (IS)
insert into orders (OrderNo,P_Id) select 12345,P_Id from persons where LastName='Hansen'; Should do it for you. Michael D. Black Senior Scientist NG Information Systems Advanced Analytics Directorate From: sqlite-users-boun...@sqlite.org

Re: [sqlite] Insert rows into a foreign key table

2011-08-15 Thread Igor Tandetnik
Black, Michael (IS) michael.bla...@ngc.com wrote: insert into orders (OrderNo,P_Id) select 12345,P_Id from persons where LastName='Hansen'; vs INSERT INTO ORDERS (OrderNo, P_Id) values ( 12345, select P_Id from persons where LastName = 'Hansen') To the OP: note that there's a subtle

Re: [sqlite] Is it okay to use SQLite + PHP for Library Software?

2011-08-15 Thread Simon Slavin
On 15 Aug 2011, at 9:46am, Raouf Athar wrote: I have to develop a Library Management System using *PHP* for a medium sized college library. The library has about 5,000 members and 50,000 books. On an average, about 500 members will look for books and will be issued books on daily basis.

Re: [sqlite] Insert rows into a foreign key table

2011-08-15 Thread Black, Michael (IS)
Good point...neither one is probably desirable... When you get to this point in your code you should already have P_Id being passed around and not have to retrieve it. Retrieving is dangerous as Igor has just described unless you have last name with a unique constraint (which would seem

Re: [sqlite] Insert rows into a foreign key table

2011-08-15 Thread Simon Slavin
On 15 Aug 2011, at 12:58pm, Igor Tandetnik wrote: Black, Michael (IS) michael.bla...@ngc.com wrote: insert into orders (OrderNo,P_Id) select 12345,P_Id from persons where LastName='Hansen'; vs INSERT INTO ORDERS (OrderNo, P_Id) values ( 12345, select P_Id from persons where LastName

Re: [sqlite] Read only scaling optimization

2011-08-15 Thread Drew Kozicki
The bottleneck appears to be mutex's locking access to the file and cache inside the same program. I'm guessing that the reason why 2 programs on 2 files on 2 hdd's did not perform as well as the one too me suggests that both hdd's do not have the same performance and that it is not access to the

Re: [sqlite] Read only scaling optimization

2011-08-15 Thread Pavel Ivanov
Just by having 2 programs access 2 different files on the same disk give that much of a performance/scaling gain causes me to believe that there exists a vital area of code that is mutexed that is the bottleneck. I hope you are talking about your OS kernel, because SQLite won't ever care

Re: [sqlite] Is it okay to use SQLite + PHP for Library Software?

2011-08-15 Thread Darren Duncan
Raouf Athar wrote: I have to develop a Library Management System using *PHP* for a medium sized college library. The library has about 5,000 members and 50,000 books. On an average, about 500 members will look for books and will be issued books on daily basis. *Kindly let me know if it is

Re: [sqlite] Insert rows into a foreign key table

2011-08-15 Thread BareFeetWare
On 15/08/2011, at 10:40 PM, Simon Slavin wrote: which is why proper code should never do it in one instruction. You do the SELECT first, then use your programming language to do the right thing for each of the three cases where 0, 1 or more records are returned. I disagree with this more

Re: [sqlite] Is it okay to use SQLite + PHP for Library Software?

2011-08-15 Thread Mr. Puneet Kishor
On Aug 16, 2011, at 1:23 AM, Darren Duncan wrote: Raouf Athar wrote: I have to develop a Library Management System using *PHP* for a medium sized college library. The library has about 5,000 members and 50,000 books. On an average, about 500 members will look for books and will be issued