Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting data out of a non-normalized database

Status
Not open for further replies.

Leakyradiator

Technical User
Jul 12, 2002
35
0
0
US
I have a database that is not normalized. It consists of categories and organizations. In some cases, where an organization is in several categories, all the organization information is repeated for each category, in some instances as often as 8 times.

The categories come from a categories table and the organizations come from a organization table, with the category ID's used as a foreign key.

What SQL code can I use to pull the organization name from the database and each of the categories that apply to it so that I can then dump it into a normalized database?

Thanks
 
want to give a sample row or two... Just relevant comon fields etc..

My thoughts are a "distinct" clause in the query.. but the "how" is difficult to say for sure without seeing some sample data..

Rob

 
A sample might be:
[PK] [FK]
Org_id Cat_id Name Address
1 102 Allen Center 134 N Street
2 134 Allen Center 134 N Street
3 135 Allen Center 134 N Street
4 145 Allen Center 134 N Street
5 102 Fred's Shop 299 Ethel Street
6 223 Fred's Shop 299 Ethel Street
7 277 Fred's Shop 299 Ethel Street
8 132 Fred's Shop 299 Ethel Street

thanks
 
Ahhh..

so do you want all categorys where the name might be "Allen Center"?

Or do you just want

Allen Center
Fred's Shop

 
OK are you sure the data for each organization is the always the same in every record that includesthat organization? This is, of course, the main problem with denormalized tables. If it is not, then how do you determine which record to pick?

Questions about posting. See faq183-874
Click here to learn Ways to help with Tsunami Relief
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top