Commit a13a0f80 authored by Craig Earley's avatar Craig Earley
Browse files

added views for call,city and complaint,type,cat,group

parent aa18d48b
......@@ -2,15 +2,10 @@
begin;
--15-00016033,2015-02-27,7:48:59,BUSINESS CK,10000 BLOCK OF WILLIAMSON RD,WILLIAMSBURG,,
--15-00028812,2015-04-12,9:29:48,BUSINESS CK,10000 BLOCK OF WILLIAMSON RD,WILLIAMSBURG,,
--15-00037121,2015-05-10,9:16:52,BUSINESS CK,10000 BLOCK OF WILLIAMSON RD,WILLIAMSBURG,,
--15-00009972,2015-02-05,7:55:16,BUSINESS CK,10000 BLOCK OF WILLIAMSON RD,WILLIAMSBURG,,
--15-00069858,2015-09-05,21:13:44,TRAFFIC STOP,1000 BLK E MAIN ST,RICHMOND,39.829063,-84.889087
-- -- Populate them from the raw and uncleaned csv
\copy calls_csv from '/cluster/home/cjearley13/DataScience/emergency-calls/2015calls.csv' with delimiter ',' csv header;
\copy response_csv from '/cluster/home/datascience/911calls/raw/departmentsdispatched.csv' with delimiter',' csv;
--\copy response_csv from '/cluster/home/cjearley13/DataScience/emergency-calls/2016departmentsdispatched.csv' with delimiter ',' csv header;
-- set to initcap so as to make life easier
update calls_csv set city=initcap(city);
......
......@@ -47,4 +47,8 @@ update call_category set group_id = call_group.group_id from call_group where ca
-- -- create any useful views
create view responding_agencies as (select response.call_id, agency.agency_name from response inner join agency on response.agency_id=agency.agency_id);
create view type_cat_group as (select call_type.complaint_name,call_type.type_name,call_category.cat_name,call_group.group_name from call_type inner join call_category on call_type.category_id=call_category.cat_id inner join call_group on call_category.group_id=call_group.group_id);
create view calls_cities as (select calls.call_id,place.city from calls inner join place on calls.place_id=place.place_id);
commit;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment