tags:

views:

39

answers:

4

I'm creating a database with what I anticipate will be a long (perhaps several paragraphs for some tuples) attribute. I'm assigning it text instead of varchar. I have two questions:

  1. Should I give a maximum value for the text field? Is this necessary? Is it useful?
  2. Since the contents of this field will be displayed on a website in HTML, do I need to include paragraph tags for paragraph formatting when I enter records into mysql?
A: 

1) I do not give max length for fields that I place HTML in, as it is variable and could always grow longer. 2) I would place all HTML in the field, but it depends on if you want to do that extra step in your application.

NOTES: Always HTML encode your HTML data before inserting to database.

Dustin Laine
+1  A: 
  1. No define it as text or mediumtext
  2. If the data will be output as HTML, store HTML tags
Andy
+3  A: 
  1. Not really, define as text.
  2. If you want to display text in HTML with formatting you will either have to build the HTML tags into the text in the database or parse before printing and add them then.
Mimisbrunnr
A: 

text field nas no length parameter.
enter whatever you with as long as it displays correctly

Col. Shrapnel