Chapter 4. Building the Database

In This Chapter

  • Using SQL to make requests to MySQL

  • Creating a new database

  • Adding information to an existing database

  • Looking at information in an existing database

  • Removing information from an existing database

After completing your database design (see Chapter 3 if you haven't done this yet), you're ready to turn it into a working database. In this chapter, you find out how to build a database based on your design — and how to move data into and out of it.

The database design names the database and defines the tables that make up the database. To build the database, you must communicate with MySQL, providing the database name and the table structure. Later, you must communicate with MySQL to add data to (or request information from) the database. The language that you use to communicate with MySQL is SQL. In this chapter, I explain how to create SQL queries and use them to build new databases and interact with existing databases.

Communicating with MySQL

The MySQL server is the manager of your database:

  • It creates new databases.

  • It knows where the databases are stored.

  • It stores and retrieves information, guided by the requests, or queries, that it receives.

To make a request that MySQL can understand, you build an SQL query and send it to the MySQL server. (For a more complete description of the MySQL server, see Chapter 1.) The next two sections detail how to do this.

Building SQL queries

SQL (Structured Query Language) is the computer language that you use ...

Get PHP and MySQL® For Dummies®, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.