Solved

store text in db with carriage return or with line breaks?

Posted on 2006-11-07
6
1,011 Views
Last Modified: 2008-03-10
hi all,
I'm curious, is it best to store text copy in a db with carriage returns or with break tags?
I've done both. With carriage returns you don't need to process the values before displaying in a text area form field. With break tags you can write it straight to html... I'm guessing break tags take less physical space to store?
Are there good reasons to go one way or the other?

thanks...
0
Comment
Question by:hc0904pcd
  • 3
  • 2
6 Comments
 
LVL 25

Expert Comment

by:kevp75
ID: 17894508
honestly, I see it more as a preference thing.  I would imagine that storing the data with extra code in it may take up more space, however it is probably minimal, and may be more benficial when it comes to displaying it.

personally, I like to store textual data as is, and then worry about formatting on the page, it may be just me, but, the way I see it is client and server have to do some work to show it to you, my thinking is split the load.  If you store more in the database, the db has more to output (not that I've seen a case like this, but...) potentially bogging down the server.

I guess a good example would be file uploading.  If you upload it directly to the database the db has to store the binary data, then you would code the page to render it.  If you upload the file to a directory, you only really need to store the filename in the db.....
0
 
LVL 6

Author Comment

by:hc0904pcd
ID: 17894593
hi kev,
I like your thinking about filenames for uploads. I like to grab the record id and use that within the filename. Keeps it simple.

With inputting data, I figure I've got to process the data a bit before whacking it into the db, so along with checking for apostrophes and a few other characters I replace carriage returns with break tags at the same time. Only downside is that when I'm in edit mode displaying that text in a text area field I have to then reverse the change and show carriage returns again. But I've got 3 standard functions which speeds it all up, 1 to process data and write to db, 1 to grab from db and display in form fields, and 1 to grab from db and display on html page (with options like get the first paragraph if required for a news snippet, and converting urls to links).

It's nice to see how other people do this.
Would be nice to make my pages more efficient if I could.
0
 
LVL 25

Accepted Solution

by:
kevp75 earned 250 total points
ID: 17894697
undertandable.  I do some processing before entering too...mainly just to strip ', and garbage html that might get inputted.

efficiency is one thing I don't think any one will ever be able to perfect, as there will always be a better way of doing things.

I use functions, subs, and classes for just about everything, put them all into specific include files (db stuf in db.inc, file stuff in file.inc, etc..)  and then include them when I need to.  It really is all personal style, like I tried to say in my last post, I try to keep the load split between server and client, that way there isn't too much of a load on either.  Sometimes it works out great and I get very fast loading pages, however sometimes it doesn't work out that wll, and some are slow....but then I try to lessen the load on the client end, and find that it makes matters worse, simply because all the processing the server has to do to process the page....
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Assisted Solution

by:gete
gete earned 100 total points
ID: 17895269
I normally apply a general rule: if it's plain text, store as is (with newline characters, e.g. CR/LF/CR+LF). If it's rich/formatted text, store with (HTML) tags. In short, I don't single out line break as an exception to decide whether to use tag or not. If it's supposed to be plain text, it may be used in other medium beside web pages, e.g. in a plain text email message, presented in a another winforms application's label control etc. Having it stored with <br> imho digress from what it's originally intended. Different case if it's a formatted text.
0
 
LVL 6

Author Comment

by:hc0904pcd
ID: 17902628
Good point gete.
I currently treat everything as formatted text as I figure that covers most circumstances I deal with.
0
 
LVL 6

Author Comment

by:hc0904pcd
ID: 17923493
thanks ...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now