Database normalization ensures data consistency in the database and minimizes the possibility of logical errors. Let's practice the database normalization!
You will work with a ShopDB
online shop database in this task. This is the new development iteration for the database you saw in the previous tasks. The shop is growing and expanding, so the development team is working on adding support for multiple warehouses. In the new online shop version, the number of products in different warehouses should be possible. The development team has already started rewriting the database creation SQL code. At this point, the database has the following tables:
Countries
, which has the following columns:ID
andName
.ProductInventory
, which has the following columns:ID
,ProductName
,WarehouseAmount
,WarehouseName
,WarehouseAddress
, andCountryID
.
- Install and configure a MySQL database server on a Virtual Machine and connect to it with the MySQL client.
- Fork this repository.
Help the development team to normalize the database ShopDB
. To do that, review and update the SQL code, which creates the database, in the task.sql
file:
- Connect to your database server.
- If you already have the
ShopDB
database on your database server from the previous tasks, delete it using theDROP DATABASE ShopDB;
statement. - Analyze the existing SQL code in the
task.sql
file to normalize the database. The database is already in the first normal form; you need to update it to the third normal form. - After updating the database schema (table structure), update the
INSERT
statements at the end of thetask.sql
file. The newINSERT
statements should populate the same test data but should do it for the database structure you defined.
Just in case you want to test your script on your database before submitting a pull request, you can do it by performing the following actions:
- Drop the
ShopDB
database using theDROP DATABASE ShopDB;
statement if you already have it on your database server. - Run the script you wrote in the
task.sql
on your database server. - Run the
test.sql
script on your database. If the script execution is finished without errors, you are ready to submit a pull request.