ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old November 16th, 2004, 04:04 PM
jeffbourassa jeffbourassa is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 20 jeffbourassa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 50 m 16 sec
Reputation Power: 0
database normalization using CFM

Hi All

I am doing some cleanup on a sales database - one of the todo items is normalizing a coding field. Currently the code field is use to filter clients based on a users filters when they login, allowing to to see part or all of the clients in the database. Some users see mutiple codes others just one code - based on filter when they view the client list. Pretty easy concept.

Now, the problem is such that this coding field has now became tough to manage and it has been decided that it should be normalized to a different table. As is usually the case this should have been done early one but hind sight is always 20-20.

This is what we have now - just a small sample - there are 12000+ records:

Code: PCBUS
ID: 3349

Code: PCBCA, PCBUS
ID: 587

Code: PCBCA
ID: 3350

I want to normalize this ending up with a coding table that looks like:

ID - code
3349 - PCBUS
587 - PCBCA
587 - PCBUS
3350 - PCBCA

etc. Currently the code are store in the client table in a field - each code is separated by commas.

So my thought was to create a CFM page that reads the IDs and codes, and then inserts accordingly into a new code table - I would need to be able to recognize the commas in the code field and loop on those - thuis duplicating the IDs being inserted accordingly.

Any suggestions, ideas on this - let me know.

Thanks

Jeff

Reply With Quote
  #2  
Old November 16th, 2004, 06:08 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
You can loop over a list. Just use your comma-delimited codes a list and loop over them, performing an insert for each one.

In pseudo-code:

cfloop query="the big query"
cfset thisListOfCodes = bigQuery.code

cfloop list="#thisListOfCodes#"
cfquery name="insertThisCodeIntoNewTable"
insert into...
/cfquery
/cfloop

/cfloop
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > database normalization using CFM


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway