mysql - Combining SQL Insert and Delete -
OK Here's the question
I have three tables
When creating an ad form, I can only search for all questions related to the special program, and show the question in an HTML form. But consider the editing scenario. Event Manager can add or remove some questions for some reason. So in such a case, when the user tries to edit the answer previously posted, then I generate the HTML form as an empty form with new questions and the existing answers are already prefilled in the input box. How do I submit this form?
When a user submits, do I delete all the previous replies for all the answers and INSERT on the answer table? Or is it a good practice to update existing answers first and include only new values?
The first DEYTE followed by INSERT, while there is some tedious problem with the former solution, that the answer table ID will increase every time ..
< Div class = "post-text" itemprop = "text">
Some people have the right to delete / insert because, as you say, this is easy.
Personally I think the update / insert / delete approach, while working more, is more accurate.
If you update, you can find out the audit test of changes for a particular item. It is very difficult or simple to do just that it is inserted / removed, which is for such kind of relationship and history.
How to update the field, how can be updated (i.e. existing record), you should be able to identify the area in any way. Personally, I say in symbolic terms just like the primary key of the field name.
If you do this then you will definitely have to make sure that you do not have a valid hole, that the validated ID is valid and editable
& lt; Input type = "text" name = "name_117" value = "some value" & gt; & Lt; Input type = "article" name = "name_118" value = "some other value" & gt; & Lt; Input type = "text" name = "name_1243" value = "yet another value" & gt;
And you have to process all the input parameters, decoding the identifier and act accordingly. Finally, another problem with inserting / removing is that you can not do this (or it becomes really hard) if the items you are removing / putting in the database Are related to the tables. If you have a question table and collect answers given to people, then in general you will refer to the question as a foreign key. If you delete / insert instead of deletion, then you lose that association.
Comments
Post a Comment