Jump to content

php fill the missing rows or gaps in mysql colum


thindrakhya

Recommended Posts

hi friends

 

 

i want to fill the gaps in the table column for the rows which are deleted

 

like i have id 1 2,3,4,5

if i delete id = 3 and insert next record then with auto_increment the next record will be added with ID 6 not at 3

 

Will it be better that when i delete any rows i will store that ids in different table column and when i need to insert any data

the i will select the min(ID) from thta column name and if there is no ID in that colum then i will use select MAX(id) from the current table

 

Is this solution viable

Link to comment
Share on other sites

The question needs to be asked. Why would you want to do this? If you are relying on your ids always being in sequence you are doing something wrong. databases are designed to be unordered collections of data.

Link to comment
Share on other sites

thanks for you help

 

I was just think thats it looks good , i don't have any particular eason for doing this

 

If u think there is no problem with un ordered list then that is better

 

I want to ask one thing if you can guide

 

In the PHPforums database desgin when all the registered users posts new topic or send reply then do all the posts from the all users store in same table with fields something like

 

post_id , sender-name , .............

 

or the posts from different users are stored in differnt tables

 

I want to know because this way post_id coulmn will be very very bigger

Link to comment
Share on other sites

In the PHPforums database desgin when all the registered users posts new topic or send reply then do all the posts from the all users store in same table with fields something like

 

post_id , sender-name , .............

 

or the posts from different users are stored in differnt tables

 

Storing each users posts in a seperate table would be rediculous. Take a look at database normalisation techniques, this should help you out with database design.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.