Creating the Sample Tables


In order to follow along with the examples, you need a set of populated tables. Everything you need to get up and running can be found on this book's web page at http://www.forta.com/books/0672327120/.

The web page contains two SQL script files that you may download:

  • create.sql contains the MySQL statements to create the six database tables (including defining all primary keys and foreign key constraints).

  • populate.sql contains the SQL INSERT statements used to populate these tables.

Note

For MySQL Only The SQL statements in the downloadable .sql files are very DBMS specific, and are designed to be used only with MySQL.

The scripts have been tested extensively with MySQL 4.1 and MySQL 5 and have not been tested with earlier versions of MySQL.


After you have downloaded the scripts, you can use them to create and populate the tables needed to follow along with the chapters in this book. Here are the steps to follow:

1.

Create a new datasource (do not use any existing datasource, just to be on the safe side). The simplest way to do this is using the MySQL Administrator (described in Chapter 2, "Introducing MySQL").

2.

Make sure the new datasource is selected (use the USE command if using the mysql command-line utility, or select the datasource if using the MySQL Query Browser).

3.

Execute the create.sql script. If using the mysql command lint utility, you can specify source create.sql; (specifying the full path to the create.sql file). If you are using the MySQL Query Browser, select File, Open Script, create.sql, and click the Execute button.

4.

Repeat the previous step using the populate.sql file to populate the new tables.

And with that you should be good to go!

Note

Create, Then Populate You must run the table creation scripts before the table population scripts. Be sure to check for any error messages returned by these scripts. If the creation scripts fail, you will need to remedy whatever problem might exist before continuing with table population.





MySQL Crash Course
MySQL Crash Course
ISBN: 0672327120
EAN: 2147483647
Year: 2004
Pages: 214
Authors: Ben Forta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net