Solved

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

Posted on 2006-11-07
6
1,010 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 6

Assisted Solution

by:gete
gete earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
thanks ...
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

11 Experts available now in Live!

Get 1:1 Help Now