Specifications

CONTENTS
xi
Web Database Architecture ................................................................180
Architecture ..................................................................................180
Further Reading ..................................................................................182
Next ....................................................................................................182
8 Creating Your Web Database 183
A Note on Using the MySQL Monitor ..............................................185
How to Log In to MySQL ..................................................................185
Creating Databases and Users ............................................................187
Creating the Database ....................................................................187
Users and Privileges ..........................................................................187
Introduction to MySQLs Privilege System ........................................188
Principle of Least Privilege ..........................................................188
Setting Up Users: The GRANT Command ..................................188
Types and Levels of Privilege ......................................................190
The REVOKE Command ..............................................................192
Examples Using GRANT and REVOKE ......................................192
Setting Up a User for the Web ............................................................193
Logging Out As root ......................................................................193
Using the Right Database ..................................................................193
Creating Database Tables ....................................................................194
What the Other Keywords Mean ..................................................196
Understanding the Column Types ................................................196
Looking at the Database with SHOW and DESCRIBE ................198
MySQL Identifiers ..............................................................................199
Column Data Types ............................................................................200
Numeric Types ..............................................................................201
Further Reading ..................................................................................206
Next ....................................................................................................206
9 Working with Your MySQL Database 207
What Is SQL? ....................................................................................208
Inserting Data into the Database ........................................................209
Retrieving Data from the Database ....................................................211
Retrieving Data with Specific Criteria ..........................................212
Retrieving Data from Multiple Tables ..........................................214
Retrieving Data in a Particular Order ............................................219
Grouping and Aggregating Data ..................................................220
Choosing Which Rows to Return ..................................................222
Updating Records in the Database ....................................................223
Altering Tables After Creation ............................................................223
Deleting Records from the Database ..................................................225
Dropping Tables ..................................................................................226
00 7842 FM 3/6/01 3:38 PM Page xi