Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 222395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:07:23+00:00 2026-05-11T19:07:23+00:00

Ok here is the question I have three tables events – id – name

  • 0

Ok here is the question

I have three tables

events
- id
- name

questions
- id
- event_id
- name

answers
- id
- question_id
- description

While generating the add form, i can simply search for all the questions belonging to particular event, and show the questions in single HTML form.

But consider the edit scenario. An event manager can in due time add or delete some questions from an event. So in such case, when the user tries to edit already posted answer, I generate the HTML form with the new questions as blank field and existing answers are prefilled input boxes. How can I handle the submission of this form?

When the user submits, should i delete all past answers and do a INSERT on the answers table for all the answer values? or is it a good practice to UPDATE existing answers first and INSERT only new values?

The former obiviously being easier with DELETE followed by INSERT. While the later is somewhat tedious. The problem with former solution is that the id of the answers table will increase every time..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:07:24+00:00Added an answer on May 11, 2026 at 7:07 pm

    Some people favour the delete/insert approach because, like you say, it is simpler.

    Personally I think the update/insert/delete approach, while more work, is more correct.

    If you do updates you can then have an audit trail of changes to a particular item. With just insert/delete it’s either much harder or plain impossible to have that kind of linkage and history.

    As for how to handle the submission of the form, for fields that can be updated (ie they’re existing records), you need to be able to identify the field somehow. Personally I just encode something like the primary key in the field name.

    If you do this you must of course ensure that you don’t have a security hole by validating that the ID supplied is valid and the edit allowed ie never trust the client.

    This could take the form of:

    <input type="text" name="name_117" value="Some value">
    <input type="text" name="name_118" value="Some other value">
    <input type="text" name="name_1243" value="Yet another value">
    

    and you have to process all the input parameters, decode the identifier and act accordingly.

    Lastly, another problem with insert/delete is that you can’t do it (or it just gets really hard) if the items you’re deleting/inserting relate to other tables in the database. If you have a question table and store the answers people give, normally you’ll reference the question as a foreign key. You lose that association if you delete/insert instead of updating.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a similar question here on SO, but I have a fairly small
There are other questions on here that sound similar but are not. I have
Here is my question : I have a huge class (HugeClass) and I wanted
Newbee question here - I have this method in the view controller m: -(void)
here's my question: I have a table TRUST(id INT, trustlevel INT) which contains records
Basic question here - I have many lines of code that look something like:
here's my question: I have an MVC3 C# application and I need to update
I have a question here regarding iPhone app submission. I have a free application
The question I have here is for some reason when the getInboxUnreadMessagesCount js function
Here is a question that I have had for some time but never actually

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.