HTML, XHTML and CSS All-In-One for Dummies - Andy Harris [247]
The difference between CHAR and VARCHAR is what happens to shorter words. When you return the value of a CHAR field, all the padding spaces are included. A VARCHAR automatically lops off any trailing spaces.
In practice, programmers rarely use CHAR because VARCHAR provides the behavior you almost always want.
Introducing MySQL
Programs that work with SQL are usually called relational database management systems (RDBMS). A number of popular RDBMSs are available:
♦ Oracle is the big player. Many high-end commercial applications use the advanced features of Oracle. It’s powerful, but the price tag makes it primarily useful for large organizations.
♦ MS SQL Server is Microsoft’s entry in the high-end database market. It’s usually featured in Microsoft-based systems integrated with .NET programming languages and the Microsoft IIS server. It can also be quite expensive.
♦ MS Access is the entry-level database system installed with most versions of Microsoft Office. While Access is a good tool for playing with data design, it has some well-documented problems handling the large number of requests typical of a Web-based data tool.
♦ MySQL is an open-source database that has made a big splash in the open-source world. While it’s not quite as robust as Oracle or SQL Server, it’s getting closer all the time. The latest version has features and capabilities that once belonged only to expensive proprietary systems.
♦ SQLite is another open-source database that’s really showing some promise. This program is very small and fast, so it works well in places you wouldn’t expect to see a full-fledged database (think cellphones and PDAs).
The great news is that almost all of these databases work in the same general way. They all read fairly similar dialects of the SQL language. No matter which database you choose, the basic operation is roughly the same.
Why use MySQL?
This book focuses on MySQL because this program is
♦ Very accessible: If you’ve already installed XAMPP (see Book VIII), you already have access to MySQL. Many hosting accounts also have MySQL access built in.
♦ Easy to use: You can use MySQL from the command line or from a special program. Most people manipulate SQL through a program called phpMyAdmin (introduced in the section “Setting Up phpMyAdmin,” later in this chapter). This program provides a graphical interface to do most of the critical tasks.
♦ Reasonably typical: MySQL supports all the basic SQL features and a few enhancements. If you understand MySQL, you’ll be able to switch to another RDBMS pretty easily.
♦ Very powerful: MySQL is powerful enough to handle typical Web server data processing for a small to mid-size company. Some extremely large corporations even use it.
♦ Integrated with XAMPP and PHP: PHP has built-in support for MySQL, so you can easily write PHP programs that work with MySQL databases.
♦ Free and open source: MySQL is available at no cost, which makes it quite an attractive alternative. MySQL offers other advantages of open-source software. Because the code is freely available, you can learn exactly how it works. The open-source nature of the tool also means there are likely to be add-ons or variations, because it’s easy for developers to modify open-source tools.
Understanding the three-tier architecture
Modern Web programming often uses what’s called the three-tiered architecture, as shown in Table 1-2.
Table 1-2 The Three-Tiered Architecture
Tier
Platform (software)
Content
Language
Client
Web browser (Firefox)
Web page
XHTML/CSS/JS
Server
Web server (Apache)
Business rules and logic
PHP (or other similar language)
Data
Data server (MySQL)
Data content
SQL (through MySQL or another data server)
The user talks to the system through a Web browser, which manages XHTML code. CSS and JavaScript