473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

SQL Query Help - - Table Normalization

hello

I've a denormalized table PRODUCTS with following fields:
ProductNo ,
OrderNo ,
SerialNo ,
OrderDate ,
PromiseDate ,
ManufacturerID ,
..
..
..
DistributorID ,
DealerID ,
..
..
..
ReceiptDate ,
..
..
..
I have to denormalize this table, so I created 3 tables:

Table Name : ProductOrders
Fields:
+ProducrOrderID,
ProductNo ,
OrderNo ,
SerialNo ,
OrderDate ,
PromiseDate ,
ManufacturerID ,
-------------------------------
Table Name: ProductsOrdersDetails
Fields:

+ProductsOrdersDetailsID,
ProductOrdersID,
DistributorID ,
DealerID
..
..
..
-----------------------
Table Name: ProductsOrdersReceipts
Fields:
+ProductsOrdersReceiptsID,
ProductsOrdersDetailsID,
ReceiptDate ,
..
..
..

----------------------------

DistributorID and DealerID appear in Details table because a
particular order number for a specific product number can come from
different distributor and dealer.
What I need is a query to populate these normalized tables from the
original denormalized Products table.

Can any one please help?

Thanks
Jul 20 '05 #1
1 1733
Muzamil (mu*****@hotmail.com) writes:
I have to denormalize this table, so I created 3 tables:

Table Name : ProductOrders
Fields:
+ProducrOrderID,
ProductNo ,
OrderNo ,
SerialNo ,
OrderDate ,
PromiseDate ,
ManufacturerID ,
-------------------------------
Table Name: ProductsOrdersDetails
Fields:

+ProductsOrdersDetailsID,
ProductOrdersID,
DistributorID ,
DealerID
.
.
.
-----------------------
Table Name: ProductsOrdersReceipts
Fields:
+ProductsOrdersReceiptsID,
ProductsOrdersDetailsID,
ReceiptDate ,
.
.
.
I think you should find the real keys of your subtables. If I understand
your narrative correctly, the primary key for ProductOrderDetails
should be (ProductOrderID, DistributorID, DealerID). In the same vein
the key for ProductsOrdersReceipts should maybe be
(ProductOrderID, DistributorID, DealerID, ReceiptDate).

In the long run this will make the data model easier to understand,
and easier to query.
What I need is a query to populate these normalized tables from the
original denormalized Products table.


Without the complete CREATE TABLE statements and sample data this
is somewhat difficult. But I would guess that for the first two
tables, you would have to use the DISTINCT keyword. But it will be
all straight-forward. At least if you follow my recommendation on the
keys.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: knoak | last post by:
Hi there, I have a table with items in it. Table contents are: id, title, text, combination Each product has a few other products with which it can be combined. In the 'combination'- field...
9
by: Ed_No_Spam_Please_Weber | last post by:
Hello All & Thanks in advance for your help! Background: 1) tblT_Documents is the primary parent transaction table that has 10 fields and about 250,000 rows 2) There are 9 child tables with...
2
by: Willem | last post by:
Hi there, I'm sort of new with doing much record manipulation with queries. Up till now I've been programming VBA and doing record looping to get my results. This works fine but tends to get...
1
by: E.U. | last post by:
Hi, I an using MS-Access in order to build a site. I have this item that can have upto 10 pictures (might have none) I want to design a dynamic table which has the ID of the item at the first...
1
by: sunilkeswani | last post by:
Hi I am still new to access. I want to know how i can build a query which can display results from 4 different columns/fields Like. Field1 Field2 Field3 Field4 1 2 1 ...
25
by: frizzle | last post by:
Hi there, I have a mySQL system with a news publishing part in it: Admins can create new items with text in it, and they have an option to create 'fulltexts', so you'd get "read more ..." on the...
9
by: PeteCresswell | last post by:
I've got something called "Reference Rates". The idea is that on a given day, we have various rates of return for various entities. e.g. Libor 3-month return, Libor 6-month return, US Treasury...
4
by: Deus402 | last post by:
Here is my table design: tblEmployers EmployerID autonum (primary key) EmployerName text tblLocations LocationID autonum (primary key) EmployerID longint (foreign key) LocationAdress text
4
by: Tess2819 | last post by:
Hi Everyone, This is my first topic so I hope you can help. I have searched but can't seem to find what I am looking for, so here it is. I want to create a query using design view in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.