tags:

views:

94

answers:

2

I was wondering if you where to have an article or articles with huge amounts of text, what would be better when creating the database structure for the articles text? And why?

What will be the advantages or disadvantages if any?.

I was thinking of using one of the data types below to hold the articles text for the MySQL database.

VARCHAR
TEXT
MEDIUMTEXT
LONGTEXT
+4  A: 

Please have a look at the Documentation of MySQL, there're the differences between these types explained.

But to answer your question, VARCHAR is a field of user-defined length, while the Text-Fields have a system-defined size:

  • VarChar [1-whatever (max at 65535)]
  • TinyText 255 (2^8 - 1)
  • Text 65535 (2^16 - 1)
  • MediumText 16M (2^24 - 1)
  • LongText 4G (2^32 - 1)

So, I use VarChar whenever I need a field which is smaller then 255.

Bobby
VARCHAR can go up to 65535 since MySQL 5.0.3
nickf
+1  A: 

For longer chunks of text, TEXT is a good choice. If you want the full text search features, be sure to set an index of FULLTEXT on the field. This will require a table in the MyISAM format. You can read more here: http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html

Frank DeRosa