User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,477 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,804 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 455 | Replies: 5
Reply
Join Date: Aug 2007
Posts: 8
Reputation: bg370 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
bg370 bg370 is offline Offline
Newbie Poster

Mysql Question

  #1  
Aug 30th, 2007
I'm posting in the PHP forum cause that's what I'm using to connect to MySQL. If there's a better place to post this let me know...

Anyway, I have data that consists of discrete lines of text which must be in a certain order. Like if you were taking a block of computer code with line numbers and storing each line as a row in a table.

That's fine, but when when it comes time to delete a line, we have a gap in the line numbers. So I have to go to each line after the deletion and decrement it's line number so that it's all in continuous order again.

I'm fine with doing that and obviously the code is pretty straightforward, but I wonder if this is the most efficient way. Is there another way of, say, structuring the data that would reduce the load on the sql server? Honestly, there aren't a ton of lines in each data set - maybe a few hundred. So it's possible that the correct answer is "don't worry about it". Just wondering.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Posts: 9
Reputation: flagbarton is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
flagbarton flagbarton is offline Offline
Newbie Poster

Re: Mysql Question

  #2  
Aug 30th, 2007
are you using php? try to use a counter in fetching the data then echo the counter, bcoz if your using the ID(autoincrement) of mysql everytime you delete you also delete(part of deletion) that number. and if not, just in mysql idont know either =p
Reply With Quote  
Join Date: Aug 2007
Posts: 8
Reputation: bg370 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
bg370 bg370 is offline Offline
Newbie Poster

Re: Mysql Question

  #3  
Aug 30th, 2007
I'm using a separate line number field to keep track of the order.
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 3,090
Reputation: Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold 
Rep Power: 15
Solved Threads: 307
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Posting Sensei

Re: Mysql Question

  #4  
Aug 30th, 2007
As long as the order of the lines does not change, why should it matter if there are gaps in the sequence? You can still sort them correctly with the gaps and generate the displayed line numbers yourself in the output as flagbarton indicated.
Reply With Quote  
Join Date: Aug 2007
Posts: 8
Reputation: bg370 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
bg370 bg370 is offline Offline
Newbie Poster

Re: Mysql Question

  #5  
Aug 30th, 2007
Yea I guess that's true, thanks. But now I'm realizing that inserts into the middle of it will screw up the order anyway. I may just need to reorder with each insert/delete unless there's another idea.
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 3,090
Reputation: Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold 
Rep Power: 15
Solved Threads: 307
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Posting Sensei

Re: Mysql Question

  #6  
Aug 30th, 2007
Well, you could get by with renumbering on insert alone, but go with whichever you prefer.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 2:38 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC