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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 234k
  • Answers 234k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The recommended way to write web services in .NET is… May 13, 2026 at 6:00 am
  • Editorial Team
    Editorial Team added an answer No, you can't write something like setSourceRGB (fromRgb rgb), because… May 13, 2026 at 6:00 am
  • Editorial Team
    Editorial Team added an answer After the ajax call $('#generic_dialog').dialog('option','buttons',{ 'OK': function(){ $(this).dialog('close');} }); May 13, 2026 at 6:00 am

Related Questions

Ok here is the question I have three tables events - id - name
I have an application written in C# which uses Linq2SQL for communicating with the
A bit background: I've got a page with a table and a number of
Summary Hi All, OK, further into my adventures with custom controls... In summary, here
Ok, so let me explain a little of what I am trying to do.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.