Just follow the instructions on the attached "WORD" documents. The final product should be for the "Week 5" document

In this lab you will create a database and a table in that database. You will insert data into the table. Show screen shots of your commands being carried out.

Creating a Database

  1. Launch MYSQL command prompt or Workbench

  2. Create a database called contacts

The command to create a database is:

CREATE DATABASE database_name;

Command:

CREATE DATABASE contacts;


To get access to your database you will carryout the USE command.


USE contacts;

Creating a Table

Before you can store data in a database, you must first create a table for your data. You do this by using the CREATE TABLE statement.

The syntax for the CREATE TABLE statement is as follows.

CREATE TABLE database_name.table_name

(column_1 data_type_1,

column_2 data_type_2,

...

[PRIMARY KEY (columns)]

);

To create a table in your default database, you do not need to qualify the table name with the database name. From now on, the book examples will use sales as the default database.

Listing 1.1 shows a CREATE TABLE statement for creating a contact_info table with four columns.

Listing 1.1: Creating a contact_info table with four columns

CREATE TABLE contact_info

(

contactID VARCHAR (6),

firstname VARCHAR (15),

lastname VARCHAR (15),

phone VARCHAR (13),

PRIMARY KEY (contactID)

);

Adding data to your table

Once you have a table, you can add data to it using the INSERT statement. The syntax for the INSERT statement is as follows

INSERT INTO table

(column_1,

column_2,

... )

VALUES (value_1,

value_2,

... )

);

For example, Listing 1.2 shows an SQL statement that inserts a row into the product table.

Listing 1.2: Inserting a row into the contact_info table

INSERT INTO contact_info

(contactID, firstname, lastname, phone)

VALUES (100, 'John', ‘Smith’, ‘718-555-1234');

After you execute the statement in Listing 1.2, your product table will have one row. You can query your table using this statement.

SELECT * FROM contact_info;

+--------+--------+-------+------------+

You can insert more than one row in an INSERT statement. The INSERT statement in Listing 1.3 add five more rows to the product table.

Listing 1.3: Adding five more rows to the product table

INSERT INTO contact_info (contactID, firstname, lastname, phone)

VALUES (100, 'John', ‘Smith’, ‘718-555-1234')

(200, 'Jane', ‘Doe’, ‘347-555-1234'),

(300, 'Fred', ‘Brown’, ‘212-555-1234'),

(400, 'Donald', ‘Duck’, ‘646-555-1234');

##############################################################################

WEEK 5 ASSIGNMENT

Make sure that the database and table are created as detailed above from week 3 assignment. Make sure the data is entered as detailed above.

Conduct the queries below and provide screenshots of your results.

Week 5 Assignment Queries:

  1. Select all contacts showing only their names.

  2. Select and show contacts phone numbers

  3. Select and show contacts with the last name Brown

  4. Select contacts with the contact ID greater than 200

Place your results as a screen shot below: