peace95 is right on. If you're building a single table DB, you're really building a spreadsheet and DBs were created to address some fundamental problems with spreadsheets.
Any item which you want to associate with more than one record, break out. You can have a customer with multiple orders, therefore its a bad idea to have columns with customer info in the same table as columns with order info. How will the customer ever order more than once?
You'll create a customer table with name, contact information, possible credit card info etc. You'll have a second order table which has an orderID column product name, product serialNumber, product price, product quantity etc. Then if you need to modify customer information you UPDATE data in the customer table. If you need to check an order you retrieve all the products that share the appropriate order#. Then you have a 3rd table with two columns one for order id and one for customer id so you can locate the customer who placed a particular order or look up orders for a particuar customer.
Also, any column which can take a value more than once break out. Otherwise a spelling error (as simple as including leading whitespace) can throw everything off and be very difficult to locate (since it still looks mostly right). Don't use values, use an id, then create a 2nd table which equates each id to the value you want represented. Compare the difficulty of locating an error in these two lists and you'll see why.
San Jose
San Jsoe
San Jose
San Jose
San Jose
1
2
1
3
1
Both of the even numbered positions are incorrect in the first list. The 2nd has the s and o in Jose transposed, a common spelling error. The 4th item as a leading space. One of the wicked problems in web apps is that HTML ignores multiple spaces, so I don't even know if this will appear in the output you're looking at, but it's still there and if you did a SELECT on "San Jose" it would not return that item even though you undoubtedly want it. It's effectively lost. In contrast it's glaringly obvious that the 2nd and 4th list items are incorrect in the second list so they are much easier to correct, in fact, its so much easier that this data would almost certainly never have gotten into the database this way in the first place.
__________________
-------------------------
Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe
When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper
Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
|