Table Normalization Help

Mac1206

Board Regular
Joined
Jun 3, 2016
Messages
184
I have a Freight table which I would like to find the most proficient approach in getting into this normalize state....Below is the sample Freight_Tbl and the second table is my goal for normalization. How can this be accomplish is my question....Thanks in Advance as always...

Freight_Tbl

City_DestState_DestPlantCity_OriginState_OriginEfffect_DateCurrencyRate_4Rate_6Rate_BBRate_BGRate_AA
Oxon HillMaryland,USUS-MA-RichmondKaleen Texas,US5/1/2015USD55.1223.2145.600
Oxon HillMaryland,USUS-MA-SeattleWashingtonSeattle,US5/2/2015USD48.52613.5500
Oxon HillMaryland,USUS-MA-PetersburgPetersburgVirginia,US5/3/2015USD35.1532.5814.500
Oxon HillMaryland,USUS-MA-Ft. DixFt. DixNew Jersey,US5/4/2015USD45.6821.532.600

<colgroup><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>

Result_Tbl needed....

City_DestState_DestPlantCity_OriginState_OriginEfffect_DateCurrencyRate_TypeRate
Oxon HillMaryland,USUS-MA-RichmondKaleen Texas,US5/1/2015USDRate_455.12
Oxon HillMaryland,USUS-MA-SeattleWashingtonSeattle,US5/2/2015USDRate_BB13.55
Oxon HillMaryland,USUS-MA-PetersburgPetersburgVirginia,US5/3/2015USDRate_632.58
Oxon HillMaryland,USUS-MA-Ft. DixFt. DixNew Jersey,US5/4/2015USDRate_BG0

<colgroup><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi, you will need to identify the column(s) for the primary key of the proposed table first.
 
Last edited:
Upvote 0
Hi, you will need to identify the column(s) for the primary key of the proposed table first.
My attempt is to just normalize the table so instead of having Rate's in each column, just have it in one column as Rate_Type and Rate...Do I need a primary key to accomplish this in Access?
 
Upvote 0
I think i was using the wrong terminology, instead of normalizing it, I just want to achieve the new design which is the second tbl instead of the first one....Sorry, learning Access on the fly with great people like the MrExcel Team...
 
Upvote 0
If you don't have a primary key in your table you can expect only pain and suffering from your database.
 
Upvote 0
If you don't have a primary key in your table you can expect only pain and suffering from your database.
That is good advice.
At the very least, add an Autonumber field and make that the Primary Key.
You don't even need to do anything once you add it to the table. It is self-populating when new records are added.
 
Upvote 0
Step for creating the new table (each sql command should be run in turn, ignoring the lines with comments):
Code:
--create the new table
select 
	City_Dest, State_Dest, Plant, City_Origin, State_Origin, Effect_Date, Currency, '' as Rate_Type, 0.00 as Rate
into 
	Freight_Tbl_2
	
--Clear the new table
delete Freight_Tbl_2.*

--STOP: Check all data types in new table for accuracy by opening the table in design view and checking it out.

--Add First Rate
insert into Freight_Tbl_2
select 
	City_Dest, State_Dest, Plant, City_Origin, State_Origin, Effect_Date, Currency, 'Rate_4' as Rate_Type, Rate_4 as Rate
from 
	Freight_Tbl

--Add Second Rate
insert into Freight_Tbl_2
select 
	City_Dest, State_Dest, Plant, City_Origin, State_Origin, Effect_Date, Currency, 'Rate_6' as Rate_Type, Rate_6 as Rate
from 
	Freight_Tbl

--Add Third Rate
insert into Freight_Tbl_2
select 
	City_Dest, State_Dest, Plant, City_Origin, State_Origin, Effect_Date, Currency, 'Rate_BB' as Rate_Type, Rate_BB as Rate
from 
	Freight_Tbl

--Add Fourth Rate
insert into Freight_Tbl_2
select 
	City_Dest, State_Dest, Plant, City_Origin, State_Origin, Effect_Date, Currency, 'Rate_BG' as Rate_Type, Rate_BG as Rate
from 
	Freight_Tbl

--Add Fifth Rate
insert into Freight_Tbl_2
select 
	City_Dest, State_Dest, Plant, City_Origin, State_Origin, Effect_Date, Currency, 'Rate_AA' as Rate_Type, Rate_AA as Rate
from 
	Freight_Tbl

When done, check the counts. The new table should have the same number of records as the old table.
 
Upvote 0
If you don't have a primary key in your table you can expect only pain and suffering from your database.
Trust me I understand but, I figured it out with the UNION ALL SQL Statement:

SELECT City_Dest, State_Dest, Plant, City_Origin, State_Origin, Effective_Date, Currency, Miles, 'Rate_4' AS Rate_Method, Rate_4 AS Rate FROM Freight_Tbl
UNION ALL
SELECT Etc....to make the new table design...Thanks and again,

I do understand how important normalization is but when they want it on the fly, we sometime have to go back and then normalize and create that Relational DB as intended...Thanks for your help...
 
Upvote 0
That is good advice.
At the very least, add an Autonumber field and make that the Primary Key.
You don't even need to do anything once you add it to the table. It is self-populating when new records are added.
Will do Joe, thanks...
 
Upvote 0

Forum statistics

Threads
1,216,027
Messages
6,128,367
Members
449,444
Latest member
abitrandom82

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top