MyBB Community Forums

Full Version: Could someone explain mysql field options?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am making a small CMS as an introduction to php. I have finished it using text files instead of a database but now i am converting it to mysql. I will need one short field and one long field but i am confused as to weather to use VARCHAR or tinytext as the short one (for username, page title etc.) and long blob or long text as the long one (For page content). Could someone also explain the other options such as Coallation, Null, Attriutes and Extra and what what values should i enter as the length? Also what does the full text option mean down the bottom and do i need to specify a primary key (i dont think i do because i was using the page name as the identifyer) and will the uneque option make it so i cant have 2 of the same page?

I know its alot of questions but i cant seem to find all these answers in one place. Thanks for the help in andvance Smile
I would generally go for VARCHAR for fields which will be less than 256 characters long, as they are more flexible.

Generally you don't need largetext - text is typically suffice.
BLOB is designed for binary objects (ie images), not really text.

Collation has something to do with character sets (I'm not sure what exactly).

The length field isn't available for BLOB/TEXT objects, but I believe it does exist for other types. It only has an effect for VARCHAR/CHAR (and probably a few other) types - it specifies the maximum allowable length in the field.
I think full text is a type of index.

Null values is a typical database construct - ie a value can be set to "null".

Primary keys, keys, unique keys, indexes etc are also database constructs. They're designed to make identifying things easier, and faster. You generally should always have a primary key for all tables.


See here for more in-depth information: http://dev.mysql.com/doc/refman/5.0/en/c...table.html
all of those are basics & main things in MySQL and you cannot start using it before you learn the basics, search for guides and tutorials and start learning!

if you have specific question come again, you're always welcome.

good-luck! Big Grin