I am going to use a single field in a MySQL table for content. This content will be over 1,000 words which must be over 5,000 characters. This content will have <p> tags and <div id=…> and <div class=…> tags for CSS Styling.
I think it is best to choose varchar (5,000). Or would you advise something else, before I start filling in the table?
Whatever loads fastest when using PHP is what I want to use!
Personally i wouldn’t recommend using VARCHAR for more then 255 characters as its not designed for it, the best option i can recommend is one of the TEXT options as they are designed for long strings.
also, consider putting the actual copy into a separate table
e.g.
CREATE TABLE cms_entries
( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT
, pagename VARCHAR(255) NOT NULL
, title VARCHAR(255) NOT NULL
, descr VARCHAR(255) NOT NULL
, url VARCHAR(255) NOT NULL
, added DATETIME NOT NULL
, chged DATETIME NULL
) ENGINE=InnoDB
;
CREATE TABLE cms_contents
( id INTEGER NOT NULL PRIMARY KEY
, content TEXT NOT NULL
) ENGINE=MyISAM
there are two advantages:
when running queries against your entries only, like for a list consisting only of title and url, the rows are shorter so the queries are more efficient
also, having the one-to-one relationship with the actual text in a separate myisam table means that you can declare a fulltext index on it, while the main entries table remains innodb
SgtLegend, I tried setting the “Length/Values” for a text field and noticed it does not save a maximum. I suppose this is because there is no maximum. I will probably use this method.
r937, I do not understand your reasoning. What are MYISAM and INNODB tables? I see you are creating tables. In other words you mean create two separate tables in MyPHPAdmin, right? But, if this is correct, how do I set the tables to MYISAM and INNODB? And what does it do to them and what are the benefits? Will it load faster?
Using VarChar(300) for an example, is handy when creating indexes. If you use TEXT you might just end up not being able to, due to the size restriction for the INDEX.