Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. ## Get Normalized
  2.  
  3. 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.
  4.  
  5. #### Directions
  6.  
  7. 1. Within `shopping_db`, create a table, `stores` for holding your store data. Each store should have:
  8. - an auto-incrementing primary key of `id`
  9. - a `name` attribute
  10. - a `slogan` attribute
  11. 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`
  12. 1. Now add a `store_id` column to the `receipts` table.
  13. 1. Now update the records in the `receipts` table so that each record gets the appropriate `store_id` value.
  14. - 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.
  15. 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