[Chicago-talk] creating relational keys
Jay Strauss
me at heyjay.com
Thu Mar 1 10:40:27 PST 2012
Hi all,
I have some data like:
CITY|STATE|ZIP
SCHAUMBURG|IL|60194
MATTESON|IL|60443
WARRENTON|OR|97146
MOUNTAIN HOME|AR|72653
FORT WORTH|TX|76107
CLEVELAND|MS|38732
WATERTOWN|SD|57201
GRAND CHUTE|WI|54913
I want to load it into a relational database in such a way that I have the
proper keys to build a hierarchy.
so for example:
ID Name ParentID
0 USA
1 IL 0
2 SCHAUMBURG 1
3 60194 2
4 MATTESON 1
5 60443 4
6 OR 0
7 WARRENTON 6
8 97146 7
...
I'm not sure of a good way to do this.
I read the data an built a hash like:
USA => {IL => {SCHAUMBURG => {60194 => 0},
MATTESON => {60443 => 0}},
OR => {WARRENTON => {97146 => 0}}
...
};
I can't think of a good way to look through it and assign the keys.
Maybe someone has done this in the past and has an elegant solution?
Thanks
Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20120301/6b547148/attachment.html>
More information about the Chicago-talk
mailing list