Jump to content

deleting from the db


jimfog

Recommended Posts

If the user decides he wants to delete some data about him in the database-his age for example. And the above being done through a form. What is the strongest indication that indeed he wants to delete info? From my experience so far I have seen that this is achieved(from a user point of view) by deleting the corresponding entry in the form field. Programmatically speaking am I going to search for an empty string in the corresponding field(age in our example) andif true make a DELETE query? Is this the way?

Link to comment
Share on other sites

I belive you need UPDATE instead of DELTE unless your user age represents whole row. Delete does delete whole row. or i am missing something?

Link to comment
Share on other sites

I do not remember about DELETE but it is possible I need UPDATE as you say. You did not answer though on how to be sure the user deleted info.

Link to comment
Share on other sites

you can update the age directly. you can set it as NULL to represents user has not entered anything or deleted age data.

Link to comment
Share on other sites

you can update the age directly. you can set it as NULL to represents user has not entered anything or deleted age data.
You mean I will set it to NULL when the table is first created or with the UPDATE query? But most importantly if I update directly the db will end up having an empty string in the age column. I do not know if this is good or bad for the db. WHat do you think? Edited by jimfog
Link to comment
Share on other sites

It all depends how you wrote the code whether or not an empty string is going to cause an error in your code.
can you be more specific?Currently I do not get an error. When I select the age from the database and pass it to an array(along with other data fron the same table)so as to be printed in the browser, age is not shown-no errors appear. What happens is that empty string occupies some space in the HTML element,nothing more. What do you suggest after saying the above?
Link to comment
Share on other sites

you need to check the value and act accordingly. if it is not empty only then print it. it can be null ,empty string or 0. your app can decide what does they represents and act upon them. i told null because it would be more relevant/appropiate to this.

Link to comment
Share on other sites

Ok I understand about the printing-if it is empty no printing. But what about the db? Can there be any complication if the property has an empty string?Can NULL be set on a property during UPDATE(in the case the user does not fill age as I state in the post above)?

Link to comment
Share on other sites

Null is not the same as an empty string. Both null and an empty string are valid values to use in a query as long as you set up your field to allow those values.
Then it comes down to the question:Use NULL or an empty string in the database?
Link to comment
Share on other sites

Then it comes down to the question:Use NULL or an empty string in the database?
It all depends how you wrote the code whether or not an empty string is going to cause an error in your code.
you need to check the value and act accordingly. if it is not empty only then print it. it can be null ,empty string or 0. your app can decide what does they represents and act upon them. i told null because it would be more relevant/appropiate to this.
you can update the age directly. you can set it as NULL to represents user has not entered anything or deleted age data.
Link to comment
Share on other sites

Then it comes down to the question: Use NULL or an empty string in the database?
These are questions for you to answer, you are the designer. I'm not designing your software or writing your code, you're doing that. You need to make the decisions like these, that's what a designer does. If you want to use null values, use null values. If you want to use empty strings, use empty strings.
Link to comment
Share on other sites

ok

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...