Re: [sqlite] trigger or application code

2010-08-10 Thread Simon Slavin
On 10 Aug 2010, at 7:45pm, David Bicking wrote: > Actually, the amount in items is a running balance of the changes. Mind you, > there are other fields in items (and in changes) that I did not show as they > didn't seem to impact this decision. > > In that 8% case where an item is to be create

Re: [sqlite] trigger or application code

2010-08-10 Thread David Bicking
Thanks Igor. Your solution was, of course, a thousand times better than the best solution I had come up with. --- On Tue, 8/10/10, Tim Romano wrote: > From: Tim Romano > Subject: Re: [sqlite] trigger or application code > To: "General Discussion of SQLite Database" > Date: T

Re: [sqlite] trigger or application code

2010-08-10 Thread Tim Romano
David, Your approach contravenes "best practice" by violating the core referential integrity paradigm: your CHANGES table refers to an item not yet in the ITEMS table and actually governs whether an ITEM item can be created. The child is giving birth to the parent. This is unnecessarily convolute

Re: [sqlite] trigger or application code

2010-08-10 Thread Igor Tandetnik
David Bicking wrote: > I am building an application with these two tables: > > CREATE TABLE changes(ChangeDate, Code, AdjAmount, Descr, Creatable); > CREATE TABLE items(Code, Amount) > > Now, what I would like to happen, I insert in to changes, and it updates the > Amount in items. > > I can g