Subject RE: [firebird-support] editing a header/detail document.
Author Sasha Matijasic
>
> Hello, I'd like to know if I'm doing things properly... All the modules
> that
> edit some document in my app, load the records from the DB into the
> edit form (I
> use local temporary tables) and when the user saves the doc. I run a
> "delete
> from header where id = _my_old_id" (the FK would also delete the child
> records)
> and then I insert all the records again. Is this a good way to do it? I
> could
> use "update" for the header record (because is only one) but an update
> wouldn't
> work for the child records, because the user can add or delete some of
> them. So
> the easiest way is to delete all of them and insert the new versions. I
> construct all the SQL locally and send a script to the database with
> all the
> changes (deletes and inserts). So far this is working fine, but I don't
> know if
> the deletes may have any impact on future performance. I'd love to hear
> some
> opinions about this !!! Thanks! -sergio
>

You are doing it all wrong. Please don't take offense, but what you described looks like a work of total newbie. You need to study the tools you use, I guarantee that there are ways to accomplish all you said, without any special coding.

There is no need to delete anything, and it is certainly not a good way to work with your data.
What language/tools you use? Depending on those, you can get few general pointers on what you need to study further.
If you continue writing code this way, very soon you'll have massive ammounts of unnecessary code that will be hard to maintain and debug. That's not the way the software is developed.

And from a perspective of database alone, it's even worse. The mere idea that you constantly delete and insert data that does not change at all is a mess. The future performance issues are least of your problems, because I frankly doubt that you can produce anything of value this way.

Sorry if I sound harsh, but you really need to study a lot and of course any questions you have related to firebird are welcome here.

Sasha