3. MySQL @ Behance
Powers Be.net
17 Dell R710s
120GB
XFS Filesystem
Percona 5.5
Sunday, January 20, 13
4. What Version of MySQL?
- Does it actually matter? Fuck yes.
mysql> SELECT VERSION()
Welcome to the MySQL monitor.
Your MySQL connection id is 54248515
Server version: 5.5.24-55-log Percona Server (GPL),
Release rel26.0, Revision 256
Sunday, January 20, 13
6. MySQL Engines
• Pluggable architecture.
• INNODB vs MyISAM
• Transactions
• Locking
• Fulltext
• Should be InnoDB for most things
http://dev.mysql.com/doc/refman/5.5/en/
storage-engines.html
Sunday, January 20, 13
12. Table Design
• Data Types
• Relations
• Normal Form
Sunday, January 20, 13
13. Data Types
• Right tool for the job
• Numeric
• String
• Temporal
• Spatial
Sunday, January 20, 13
14. Integer Data Types
• How big?
• Signed or unsigned?
• What the hell does that number in parens
mean?
• Integer types are great for storing things like
type attributes.
Sunday, January 20, 13
15. Integer Table
CREATE TABLE IF NOT EXISTS `integers` (
`tiny` tinyint(4) NOT NULL,
`tiny_zerofill` tinyint(10) unsigned zerofill NOT NULL,
`small` smallint(6) NOT NULL,
`medium` mediumint(9) NOT NULL,
`int` int(11) NOT NULL,
`int_unsigned` int(10) unsigned NOT NULL,
`big` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Sunday, January 20, 13
16. Decimals
• Fixed Point
• DECIMAL (5,2)
Sunday, January 20, 13
17. Text Datatypes
• CHAR (0 to 255)
• VARCHAR (0 to 65,535) + length
Sunday, January 20, 13
18. Bigger Text Datatypes
• TINYTEXT
• TEXT
• MEDIUMTEXT
• LONGTEXT
http://dev.mysql.com/doc/refman/5.5/en/string-type-overview.html
Sunday, January 20, 13
19. Character Sets + Collation
• A Character Set is a set of symbols and
encodings.
• Collation is the set of rules for comparing
characters.
• utf8 / utf8_unicode_ci is best bet for most
Western languages.
Sunday, January 20, 13
20. Temporal
• DATE
• TIME
• DATETIME
• TIMESTAMP
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-types.html
Sunday, January 20, 13