Search code examples
mysqlcontent-management-systemeditorblogsrichtext

what type of the data should I store in MySql that edited by rich text editor?


I am building my blog by php and MySql, and I want to use a rich-text editor like CKEditor to edit my articles at the back end. So what type of data should I store in MySql, just text, or BLOB? As far as I know, the results of the rich-text editor is in the type of html, so is it okey if I just store them as "string" that is text, which would be better for full-text search? Thanks in advance.


Solution

  • HTML is just text so store it as VARCHAR or TEXT. It is okay to store as string (types mentioned).

    Your full-text search will be improved by indexing. If you store InnoDB database engine, you lose FULLTEXT type indexing that the default MyISAM supports so you need to determine your database engine. Either way, you'll be able to search pretty fast if database indexes fit in memory.

    Full text search may be better with a 3rd-party index like Sphinx. Another thing you can do is tokenize every string in the article as separate records and "score" matches to your query (also split) but that is same thing search engines like Sphinx do and much more efficient.