MySQL and mSQL

Randy Jay Yarger, George Reese, and Tim King

O'REILLY* Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo Table of Contents

Preface ...„ ix

L Getting Started with MySQL and mSQL /

/. Introductton to Relational 3 What Is a ? 4 What Is a Relational Database? 5 Applications and Databases 6 MySQL and mSQL 7 2. Database Design 13 Database Design 13 Normalization 16 A Logical Data Modeling Methodology 25 Physical Database Design 26 3. Installation 30 MySQL 30 mSQL 37

4. MySQL 39 Design 39 Installing MySQL 41 Running MySQL 41 Database Administration 42

v yi_ Table ofContents

MySQL Utilities 58 Performance Tuning 62 5. mSQL 68 Design 68 mSQL Versions 70 Installing mSQL 72 Running mSQL 73 Database Administration 77 mSQL Utilities 84 6. SQL According to MySQL and mSQL 90 SQL Basics 90 Creating and Dropping Tables 93 SQLDatatypes 94 Indices 100 Sequences and Auto-Incrementing 101 Managing Data \ 103 Queries 105 Extended Functionality 109 7. Other Mid-Range Database Engines 113 What Is "Free"? 113 What MySQL and mSQL Lack 114 PostgreSQL 117 GNU SQL 118 Beagle 119 Making Comparisons 119

IL Database Programming 121

8. Database Application Architectures 123 The Client/Server Architecture 123 Data Processing 124 Object/Relational Modeling 125 The Three-tier Architecture 127 9- CGI Programming 130 What Is CGI? 130 HTMLForms 131 Table of Contents vii

The CGI Specification 136 Important Considerations for CGI Scripts 143 CGI and Databases 152

10. .. 154 DBI 154 An Example DBI Application 161 Msql.pm 165 MysqlPerl 174 11. Python 181 Basic Connectivity 181 Dynamic Connectivity 184 12. PHP and Other Support for Database-driven HTML 187 Alternatives for Dynamic Content on the Web 187 W3-mSQL 189 PHP 193 EmbeddedPerl 195 13. Cand ++ 197 The Two APIs 197 Object-oriented Database Access in C++ 203

14. Java and JDBC. 216 WhatlsJDBC? 216 Simple Database Access 221 DynamicTDatabase Access 224 A Guest Book Servlet 227

III. Reference 229

15. SQL Reference 231 MySQL SQL 231 mSQLSQL 269 16. MySQL and mSQL System Variables 275 MySQL System Variables 275 mSQL System Variables 280 viii _ Table of Contents

17. MySQL and mSQL Programs and Utilities 284 MySQL Utilities 284 mSQL Utilities 299

18. PHP and Lite Reference 303 PHP 303 Lite 334

19. C Reference 345 MySQL C API 345 mSQL C API 36I

20. Python Reference 368 Module: MySQL 368 Module: mSQL 372

21. Perl Reference 375 Installation 375 DBI.pm API 37J Msql.pm API 396 Mysql.pm API 412

22. JDBC Reference 416 Index •. 469

s