Challenge: Create Indexes

Test what we’ve learned so far with this challenge.

We'll cover the following

Problem statement

We have a table that contains seven products. The products table structure is given below: The id int(11) represents the primary key. The name varchar(255) represents the name of the product. The price represents the price of a particular product.

Task

Write a query that inserts a product with a name that already exists in the products table. Use another query before insert to make sure that inserting the duplicate name throws an error and restricts us from doing so. Use the products table below:

id	name	                 price
1	Game of Thrones-S01-DVD	 50.00
2	Of Mice and Men	         19.80
3	A Nice Story	         5.00
4	War Games	             70.00
5	Spider Man	             55.80
6	Avengers	             40.00
7	The Godfather	         90.00

As we can see above, we have seven records in the products table. Complete the task below:

Get hands-on with 1400+ tech skills courses.