WeCodeAcademy

Practice: A Design Review

Finally, review a design the way a database engineer would. This table was built in a hurry. Find what is wrong, then fix it with the ideas from the course: one value per cell, no repeated facts, keys, constraints.

Problems to spot: the customer's phone and city repeat on every order; several items sit in one text column; nothing stops a negative quantity; and there is no primary key on the orders.

Examplepython
Open in editor »
Quick check

Which change fixes 'rice,oil' stored in one cell?

Your turn: write the code

Add a CHECK that qty > 0, then try to insert qty -1 and print refused if the database rejects it.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.