Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this exercise, you will create a database to contain tables of batting statistics for major league baseball teams. You will then create a table

In this exercise, you will create a database to contain tables of batting statistics for major league baseball teams. You will then create a table named teamstats in the baseball_stats database and add records to the new table from a fi le named team_stats.txt in your Projects directory for Chapter 7.

1. Log in to MySQL Monitor with your root account or with the user name and password you created.

2. Enter the following command to create a database named baseball_stats: mysql> CREATE DATABASE baseball_stats;[ENTER ]

3. After you see the Query OK message, enter the following command to select the baseball_stats database: mysql> USE baseball_stats;[ENTER ]

4. After you see the Database changed message, type the following command to ensure that you selected the baseball_stats database: mysql> SELECT DATABASE();[ENTER ]

5. Enter the following command to create the teamstats table. The Team field uses the VARCHAR data type. Eleven of the columns use INT data types, and the remaining two fields use FLOAT data types. Each of the statistical fi eld names uses common baseball abbreviations, such as G for games, AB for atbats, R for runs, and HR for home runs. mysql> CREATE TABLE teamstats (Team VARCHAR(50), FirstYear INT,[ENTER ] G INT, W INT, L INT, Pennants INT, WS INT,[ENTER ] R INT, AB INT, H INT, HR INT, AVG FLOAT,[ENTER ] RA INT, ERA FLOAT);[ENTER ]

6. After you see the Query OK message, enter the following command to display the structure of the new table: mysql> DESCRIBE teamstats;[ENTER ]

7. Enter a LOAD DATA statement that inserts records from the team_stats.txt fi le in your Projects directory for Chapter 7 into the teamstats table. Replace path_to_PHP_folders with the full path for your PHP_Projects directory for Chapter 7. mysql> LOAD DATA INFILE 'path_to_PHP_folders/ Chapter.07/Projects/team_stats.txt'[ENTER ] INTO TABLE teamstats;[ENTER ]

8. After you see the Query OK message, enter the following command to view all the records in the teamstats table: mysql> SELECT * FROM teamstats;[ENTER ]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions