php - Handling updating of data with "has many" relationships in web applications -


So I have a situation that has arisen some time in web applications. I think the better way to handle it Should, therefore, I extend my current technique and hopefully some of you more experienced developers can recommend better options.

Essentially this problem revolves around editing data with many relationships in an app using a relational database for data collection (especially, I often use MySQL).

So we imagine this database schema (though it can be any similar set-up): <

The user has many skill skills for the user.

When I create a new user, I will fill some basic skills as well as some (or none) skills when I click save, my app will take this data and A new one with zero, one or several skill entries in the database The user can save.

Now, when I edit this user, I will show a form, the user's basic information, and in many fields for each skill, I can choose to remove skills, add new skills or both.

Currently, I handle this by removing the fields using Javascript and I also add new skill areas using javascript. When I click "Remove", then I would not want to delete a skill from the database immediately, but remove the field by removing the field and then delete the field after the user submits the form.

In my server side code, I usually handle this by removing all previous skill entries for this user and then save it to all posted skill entries. The second option is to remove only the skill entries that are not posted in the Skill Entry ID, then update the records for all those Posted in.

Is this a good way to handle it? Is there a better way to manage it? I am open to any suggestion, even though the procedure is quite different from what I am doing now.

For more reference, I am doing this in a PHP and MySQL app.

Thank you!

It's better to rewrite all the skill fields whenever you get the data.

If you delete the non-posting skills, then you have to compare a lot.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -