Peter Lai thinks you've done a great job on the shopping_db
database, but now he wants you to normalize our data, ie split the repetitive parts into their own tables.
- Within
shopping_db
, create a table,stores
for holding your store data. Each store should have:
- an auto-incrementing primary key of
id
- a
name
attribute - a
slogan
attribute
- Create an entry in the
stores
table for each of the stores that appears in thereceipts
table, passing in borderline creative dummy data forslogan
- Now add a
store_id
column to thereceipts
table. - Now update the records in the
receipts
table so that each record gets the appropriatestore_id
value.
- Example: If
Sears
is assigned an id of 3 in the stores array, update all thereciepts
for Sears purchases with astore_id
of 3.
- Now drop the
store
column in thereceipts
table. It's redundant and less informative than our new data-rich table.