From: Michael Orlitzky Date: Wed, 27 Jan 2010 23:04:48 +0000 (-0500) Subject: Added the SQL scripts to combine the sf1_blocks and tiger_blocks tables. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;ds=inline;h=348d73e051e750a1d750388aeba681074c1cc5e6;hp=eb51c39a919ac83319a6ced262051e6f8b0f00c4;p=dead%2Fcensus-tools.git Added the SQL scripts to combine the sf1_blocks and tiger_blocks tables. --- diff --git a/sql/combine-block-tables.sql b/sql/combine-block-tables.sql new file mode 100644 index 0000000..3f49206 --- /dev/null +++ b/sql/combine-block-tables.sql @@ -0,0 +1,21 @@ +/* + Combine the sf1_blocks and tiger_blocks tables into one + comprehensive "blocks" table. Once we're done, we drop + sf1_blocks and tiger_blocks. +*/ +INSERT INTO blocks + (SELECT sf1_blocks.id, + sf1_blocks.state, + sf1_blocks.county, + sf1_blocks.tract, + sf1_blocks.block, + sf1_blocks.blkidfp00, + sf1_blocks.pop100, + sf1_blocks.total_area, + sf1_blocks.population_density, + tiger_blocks.the_geom + FROM sf1_blocks INNER JOIN tiger_blocks + ON sf1_blocks.blkidfp00 = tiger_blocks.blkidfp00); + +DROP TABLE sf1_blocks; +DROP TABLE tiger_blocks; diff --git a/sql/create-blocks-table.sql b/sql/create-blocks-table.sql new file mode 100644 index 0000000..97d8f2f --- /dev/null +++ b/sql/create-blocks-table.sql @@ -0,0 +1,17 @@ +/* + Create a new "blocks" table to comprise the + sf1_blocks and tiger_blocks tables. +*/ + +CREATE TABLE blocks ( + id SERIAL PRIMARY KEY, + state varchar(2) NOT NULL, + county varchar(3) NOT NULL, + tract varchar(6) NOT NULL, + block varchar(4) NOT NULL, + blkidfp00 varchar(15) NOT NULL, + pop100 integer NOT NULL, + total_area double precision NOT NULL, + population_density double precision NOT NULL, + the_geom geometry NOT NULL +);