473,325 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Updating selected options Logic

2
Hi!,
can some help me with a problem?

Here are my tables: User, Profiles, and one for "Profiles per user"

In the last one, I save the ID of the user and the ID of the profiles for that user. This profiles are selected through checkboxes. My question is, What's the best way to update the records on the database?,
because there's three scenarios, they selected a new profile (INSERT), they leave like it was (NOTHING), or they unselected a profile (DELETE).

But I can't figure out a "nice" way to do this. Should I just erase all the records from the table, and then insert all the new ones even if there are unchaged records?,
Any ideas?
Mar 17 '08 #1
3 1245
ck9663
2,878 Expert 2GB
This would mean there can be multiple profiles per user.

Why don't you just add a ProfileStatus field that you can just change to 0 for Inactive simulating a DELETE and 1 for active simulating an INSERT or a reactivation of a profile.

For me, this would take 2 steps. INSERT those that are not yet on the profile and activate those SELECTED (if the record is currently selected it will overwrite the same value - which is 1).

-- CK
Mar 18 '08 #2
Assuming that you want a user to have many profiles, there is more than one way to do this.

One:
The user presses "Save", and their information is deleted from the database, and the new information saved. This is the option you have mentioned.

Two:
The user presses "Save". The code (eg .NET) checks for profiles that have been marked as "Delete", and deletes them. The code checks for profiles that have been added, and adds them. The code then updates the rest.

Three:
There is a "Save" button on each Profile line on the screen, and the user saves after each change. This will make it easier for you to manage, but I guess it depends how many changes the user makes at one time. They might get sick of pressing the "Save" button after a while.

There is no right answer here. They are all valid choices. Personally, I would either go for option one and make sure I wrapped it in a transaction in case something went wrong half way through, or go for option two.

Hope this helps
Mar 19 '08 #3
royd16
2
Ok, Thanks! I just want to use the option that gives me the best performance gain.
seeing this options I think I'll try option number two.

Thanks again
Mar 19 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
5
by: Raffi | last post by:
Hi folks, I'm new to JavaScript and need some help. I have a form with a select field. Depending on what is selected in this field, I want to display or not display another select field. For...
1
by: smash2004 | last post by:
I want to keep selected values in select list when i click on another option...with a click on a mouse... if i have 3 options in select list and i click first option..it gets selected..if i then...
7
by: webmaster | last post by:
I have a form that is using HTML and PHP to make calculations for an order form. One of the fields is asking for a total number of workstations. I would like this field to be a real-time total of...
14
by: el_sid | last post by:
Our developers have experienced a problem with updating Web References in Visual Studio.NET 2003. Normally, when a web service class (.asmx) is created, updating the Web Reference will...
3
by: John Walker | last post by:
Hi, On an ASP.NET page I have a drop down list control. When the user pulls down the list and makes a selection, I perform validation, and if the validation fails I want the selected item in...
2
by: Rob Long | last post by:
Hi I have an HTML select element in my page and it's multiple property is disabled (one item at a time mode) but I still want to transfer all the items in the select to the server when the form...
6
by: rsteph | last post by:
I've got an option group with 5 options, with no default value. Whenever I open the form and scroll through records all of the options are grey'd, unless the user selects one. What I would like to...
1
by: yasminussain | last post by:
Hi to all, I have written one jsp file. In that file, I have one drop down which contains list of request name (like student name) based on the selected value within drop down I will display the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.