Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
MrKicks
Starting Member
6 Posts |
Posted - 2004-10-30 : 04:52:37
|
| Is there a point where you can be too normal?I am working on an Ecommerce Project where the ingredients of the products are to be displayed. Each Product may have up to 30 ingredients and each ingredient has on Medicinal/healing atribute.After reading several articles about normalization I feel that I should do my best to "Be Normal" but in my starting to design the DB it looks as if this is going to add a tremendous amount of work to not only enter data initially but in my queries and updating.And if I were to Normalize is this how I would do it?Table - Products1 prod1 Price2 Prod2 Price3 Prod3 PriceTable - ProdToIngredientsColumn 1 is Product reference, Column 2 is Ingredient reference1 11 21 42 12 22 3Table - Ingredients1 Ingred1 Atribute2 Ingred2 Atribute3 Ingred3 Atribute4 Ingred4 AtributeThank You,MrKicks |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-10-30 : 07:17:51
|
yes. that's a classic many to many relationship. perfectly ok.Go with the flow & have fun! Else fight the flow |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-10-30 : 07:29:42
|
| You can set up a Stored Procedure that receives all the data from the user's data entry form and stores it into the [multiple] appropriate tables - if that helps!Kristen |
 |
|
|
MrKicks
Starting Member
6 Posts |
Posted - 2004-10-30 : 23:29:07
|
| Thank you both. It just seems like a lot of work to set this up and once setup I will need complicated (to me anyway!) queries to gather all the data from several tables just to put it back to a single row of usable data. I guess I am just missing the benefits. When I want to pull the data back out am I using a stored procedure as well?My Product table will be similiar to the following:Ref(n) = Reference to a reference table that will reference another table that I want data from. (if that makes any sense) ID Name Description Ref1 Ref2 Ref3 Ref4 Ref5 PriceIf there was only one Referenced Column I can get the data with a join, however, when I add the second reference column I am lost. Is it still a join I will be doing? All the data in all the tables will be based on the 'ID' column.Any pointers to good books, articles or tutorials dedicated to Querying Normalized data would be much appreciated.Thanx again,MrKicks |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-10-31 : 01:47:06
|
| "When I want to pull the data back out am I using a stored procedure as well"Probably preferable for three main reasons:1) Users have permission for the SProc, and not for the table2) Performance should be faster as SQL Server will cache the query plan3) The "business rules" behind pulling back the data can be adjusted in the SProc in the future (this includes WHERE you get the data from - so you can change the structure of your database without needing to change the aplpication- the SProc will still return X, Y and Z ...You could create a VIEW that has all the JOINs in place, so that you don't have to remember/type them each time.SELECT P.ProductRef, P.ProductCode, P.ProductDescrtption,I.IngredientCode, I.IngredientAttributeFROM Products PJOIN ProdToIngredients PION PI.ProductRef = P.ProductRefJOIN Ingredients ION I.IngredientsRef = PI.IngredientsRef(Put "CREATE VIEW MyViewName AS" in front of that SELECT statement if you want to create a view)Kristen |
 |
|
|
|
|
|
|
|