Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Get Normalized
- 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.
- #### Directions
- 1. 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
- 1. Create an entry in the `stores` table for each of the stores that appears in the `receipts` table, passing in borderline creative dummy data for `slogan`
- 1. Now add a `store_id` column to the `receipts` table.
- 1. Now update the records in the `receipts` table so that each record gets the appropriate `store_id` value.
- - Example: If `Sears` is assigned an id of 3 in the stores array, update all the `reciepts` for Sears purchases with a `store_id` of 3.
- 1. Now drop the `store` column in the `receipts` table. It's redundant and less informative than our new data-rich table.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement