Adding a natural key to a database table using straight GORM
I wanted to create a table of US Zip code data.
Just the 5, not the 5+4 or 5+4+2 variety…
Something that would house this kind of data.
I noticed my buddy Duncan Sommerville had written a post when I did a Google on this, but I wanted to give an alternative solution to this based on something I’d read in Robert Fischer’s GORM + GSQL book (P73-74).
I experienced difficulty getting the ‘length:5’ constraint to play ball in generating a MySQL schema based a 5 character key, per DGG 2nd ed P 47, so I’d end up with a five character natural key, but found specifying the constraint of ‘size:5..5′ worked a treat.
For the inquisitive amongst you, my odd class USZip100sRange is based on this data.
Hope you Enjoy! :-)