Solved

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

Posted on 2006-11-07
6
1,014 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP/VB email question 4 62
Reg Exp to extract Url from string asp 12 39
asp classic find word in string and get its value 7 34
Validating Date Part2 2 27
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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/…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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