wiki:Normalization

Version 14 (modified by 235018, 12 days ago) ( diff )

--

Normalization

Denormalized form

Below is an example of a denormalized table representing all information in one large relation. Notice that several columns contain multiple values (images, colors, addresses, products, etc.), which violates First Normal Form.

order_num client_name client_email delivery_address product_code(s) product(s) product_images product_colors product_price order_quantity store_ID store_name store_rating employee store_owner order_status payment discount review-comment order_rating request request_problem report_profit monthly_profit order_total sales_trend
0012025000001 Marija Kostova marija@… st.Turisticka 5, Bitola 00100001 Handmade Wooden Chair chair.jpg Brown 700 1 001 WoodCraft Skopje 4.6 Antonio Trajkovski Marko Petrovski Delivered Cash 0.04 Great quality, slightly late delivery 4.5 001112025001 Late delivery 125000 12500 700 Increasing
0022025000001 Ivan Stojanov ivan@… st.Partizanska 10, Skopje 00200002 Decorative Wall Hanging wall_hanging.jpg White & Pink, Black & Gold, Orange-Green-Purple 199 2 002 Fox Crochets 4.8 Sara Vaneva Sara Vaneva Placed Order Credit Card 0.0 Excellent craftsmanship 5.0 002122025001 Military Discount 98000 8000 350 Stable
0022025000002 Ivan Stojanov ivan@… st.Partizanska 10, Skopje 00200001 Heart Crochet crochet-heart-red.jpg, crochet-heart-blue.jpg Blue, Red, Yellow, Green 150 3 002 Fox Crochets 4.8 Sara Vaneva Sara Vaneva Packaging PayPal 0.0 Beautiful handmade product 5.0 98000 8000 50 Stable
0012025000002 Antoneta Mariovska mariovskaantoneta@… st.32 4, s.Cucer-Sandevo 00100001,00200001 Wooden Chair, Heart Crochet chair.jpg, crochet-heart-red.jpg Brown, Blue, Red 850 2 001,002 WoodCraft Skopje & Fox Crochets 4.0 Antonio Trajkovski Marko Petrovski Packaging Credit Card 0.05 Very satisfied 5.0 003122025001 Packaging question 223000 20500 750 Increasing
0022025000003 Ivan Stojanov ivan@… st.Partizanska 10, Skopje 00200002 Decorative Wall Hanging wall_hanging.jpg Black & Gold 199 1 002 Fox Crochets 4.8 Sara Vaneva Sara Vaneva Placed Order Credit Card 0.02 Wonderful decoration 5.0 004122025001 Shipping question 98000 8000 350 Stable

Problems with the Denormalized Table

This table contains several issues:

  • Multiple products may appear in one order.
  • A product may have multiple colors.
  • A product may have multiple images.
  • Client information repeats for every order.
  • Store information repeats for every product sold.
  • Employee and boss information repeats.
  • Reports and profits repeat for every order.
  • There are repeating groups, making updates difficult.
  • Insertion, deletion, and update anomalies may occur.

Because of these problems, the table is not in First Normal Form.

First Normal Form(1NF)

To achieve 1NF:

  • Every column must contain atomic values.
  • No repeating groups.
  • No lists inside cells.
  • Every row represents exactly one occurrence.

Instead of storing several colors or images in one field, each value gets its own row.

CLIENT

client_id First Name Last Name Email |
1 Ivan Stojanov ivan@…
2 Marija Kostova marija@…
3 Antoneta Mariovska mariovskaantoneta@…
Note: See TracWiki for help on using the wiki.