Practical exercises
Before you start with the following exercises, please ensure that you have successfully completed the database setup mentioned in the Technical requirements section.
Practical exercise 1
Create a database with the name Packt_database
and then verify whether the database is created correctly:
CREATE DATABASE Packt_database;SHOW DATABASE;
Practical exercise 2
Create two tables within Packt_database
, one customer and one product table, with the following columns and data types:
- Customer table:
Customer_ID
,Customer_name
,Customer_country
, andCustomer_gender
- Product table:
Product_ID
,product_description
, andCustomer_ID
Create table packt_database.customer( Customer_ID int primary key identity (1,1), Customer_name varchar (255), Customer_country varchar (255), Customer_gender varchar (2) ); Create table packt_database.product ( Product_ID int primary key identity (1,1), Product_description varchar (255), Foreign key (Customer_ID) REFERENCES customer(Customer_ID) );
Practical exercise 3
Add an additional column named product_cost
to the product table created in the previous exercise:
ALTER TABLE packt_database.product ADD product_cost varchar(255);
Practical exercise 4
You can continue practicing the learned concepts from SQL zoo link below: