Solved

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

Posted on 2006-11-07
6
1,018 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
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/…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

622 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