Web Development Exercise 7-1
In this project, you will create a database to contain tables of batting_x000D_
statistics for major league baseball teams. You will then create a table_x000D_
named teamstats in the baseball_stats database and add records_x000D_
to the new table from a file named team_stats.txt in your Projects
_x000D_
1. Log in to MySQL Monitor with your root account or with the_x000D_
_x000D_
user name and password supplied by your ISP or instructor._x000D_
2. Enter the following command to create a database named_x000D_
baseball_stats:_x000D_
mysql> CREATE DATABASE baseball_stats;[ENTER ]_x000D_
_x000D_
3. After you see the “Query OK” message, enter the following_x000D_
command to select the baseball_stats database:_x000D_
mysql> USE baseball_stats;[ENTER ]_x000D_
4. After you see the “Database changed” message, type_x000D_
the following command to ensure that you selected the_x000D_
baseball_stats database:_x000D_
mysql> SELECT DATABASE();[ENTER ]_x000D_
_x000D_
5. Enter the following command to create the teamstats table._x000D_
The Team field uses the VARCHAR data type. Eleven of the col- 439_x000D_
umns use INT data types, and the remaining two fields use_x000D_
FLOAT data types. Each of the statistical field names uses com-_x000D_
mon baseball abbreviations, such as G for games, AB for at-_x000D_
bats, R for runs, and HR for home runs._x000D_
mysql> CREATE TABLE teamstats (Team VARCHAR(50),_x000D_
FirstYear INT,[ENTER ]_x000D_
-> G INT, W INT, L INT, Pennants INT, WS INT,[ENTER ]_x000D_
-> R INT, AB INT, H INT, HR INT, AVG FLOAT,[ENTER ]_x000D_
-> RA INT, ERA FLOAT);[ENTER ]_x000D_
_x000D_
6. After you see the “Query OK” message, enter the following_x000D_
command to display the structure of the new table:_x000D_
mysql> DESCRIBE teamstats;[ENTER ]_x000D_
_x000D_
7. Enter a LOAD DATA statement that inserts records from the_x000D_
team_stats.txt file in your Projects directory for Chapter 7_x000D_
Use the_x000D_
into the teamstats table. Replace path_to_PHP_folders with_x000D_
MySQL serv-_x000D_
the full path for your PHP_Projects directory for Chapter 7. er’s direc-_x000D_
mysql> LOAD DATA INFILE 'path_to_PHP_folders/ tory path,_x000D_
Chapter.07/Projects/team_stats.txt'[ENTER ] not the Web_x000D_
-> INTO TABLE teamstats;[ENTER ] URL path._x000D_
_x000D_
8. After you see the “Query OK” message, enter the following_x000D_
command to view all the records in the teamstats table:_x000D_
mysql> SELECT * FROM teamstats;[ENTER ]_x000D_
"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.
Discount Code: CIPD30
Click ORDER NOW..


