cambridgema-gov/commercial-district-customer-intercept-survey-ibuz-brbz
Icon for Socrata external plugin

Query the Data Delivery Network

Query the DDN

The easiest way to query any data on Splitgraph is via the "Data Delivery Network" (DDN). The DDN is a single endpoint that speaks the PostgreSQL wire protocol. Any Splitgraph user can connect to it at data.splitgraph.com:5432 and query any version of over 40,000 datasets that are hosted or proxied by Splitgraph.

For example, you can query the commercial_district_customer_intercept_survey table in this repository, by referencing it like:

"cambridgema-gov/commercial-district-customer-intercept-survey-ibuz-brbz:latest"."commercial_district_customer_intercept_survey"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "what_would_you_eliminate_from_the_district", -- This open-answer response let respondents share what they would eliminate about the district.
    "what_would_you_change_abou_the_district", -- This open-answer response let respondents share what they would change about the district.
    "what_is_one_word_you_use_to_decribe_the_district", -- Respondents were asked to provide one word to describe the commercial district.
    "ethinicity", -- Respondents were asked about their ethnicity.
    "what_discourages_you_from_shopping_in_district",
    "what_would_make_you_shop_visit_more_often_in_district",
    "please_tell_me_3_types_of_businesses_you_would_like_to_see_in_t", -- An open response question which was coded by volunteers as data was inputted from paper copies.
    "what_particular_businesses_are_you_visiting_today", -- An open response question which was coded by volunteers as data was inputted from paper copies.
    "what_is_the_primary_purpose_for_being_in_district_today", -- An open response question which was coded by volunteers as data was inputted from paper copies.
    "how_do_you_most_frequently_get_to_the_district", -- * The surveys for Alewife and Inman are the only ones that combined the dining/entertainment questions. To facilitate analysis, we took their responses to the combined question and put them in both the "dining" and "eating" questions that the other surveys were asked.
    "how_many_times_a_month_do_you_come_to_district_for_dining_in_ev",
    "do_you_work_in_cambridge", -- Respondents were asked if they work in Cambridge.
    "which_types_of_businesses_would_you_like_to_see_in_district", -- Some years, this was open response, whereas other years there was a menu to select from
    "ranking_of_convenience_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_fitness_centers_gyms", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_specialty_food_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_healthcare_dentists_doctors", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor." 
    "how_important_is_the_presence_of_cultural_events_in_the_distric",
    "ranking_of_restaurants_take_out", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "do_you_go_to_school_in_cambridge", -- Respondents were asked if they go to school in Cambridge.
    "ranking_of_movie_theaters_entertainment", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "race", -- Respondents were asked about their race.
    "survey_year", -- The year in which that district was surveyed
    "language", -- Respondents were asked what language, other than English, they speak at home.
    "ranking_of_restaurants_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_home_goods", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_grocery_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "do_you_want_more_restaurants_sit_down",
    "ranking_of_florists", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_pharmacy", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_apparel_clothing_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "district", -- The district in which the survey was administered
    "how_would_you_rate_access_to_parking", -- Respondents were asked to rank each characteristic "good," "fair," or "poor."
    "how_would_you_rate_the_range_of_goods_and_services_available",
    "how_important_are_the_business_hours_within_the_district",
    "how_would_you_rate_access_to_public_transit",
    "residency", -- Respondents provided their zip code of residency. We have removed these answers to protect respondents' privacy, but coded the zip codes based on whether they were in Cambridge or not.
    "homeownership", -- Respondents were asked whether they owned or rented their home.
    "how_often_do_you_use_services_or_shops_in_district", -- Respondents shared how often they use services or shops in the district, excluding work.
    "ranking_of_sporting_goods", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_dry_cleaners_tailors", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_food_trucks", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_farmer_s_markets", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_book_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "do_you_want_more_healthcare_offices_doctors_dentists",
    "ranking_of_accessories_stores_shoes_jewelry", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor." 
    "do_you_want_more_pharmacies",
    "do_you_want_more_fitness_centers_gyms",
    "do_you_want_more_movie_theaters_entertainment",
    "do_you_want_more_specialty_retail",
    "do_you_want_more_specialty_food_stores",
    "do_you_want_more_book_stores",
    "do_you_want_more_hardware_stores",
    "how_would_you_rate_the_friendliness_of_the_district",
    "how_would_you_rate_the_quality_of_goods_and_services_available",
    "gender", -- Respondents were asked their gender.
    "how_important_is_parking", -- Respondents were asked to assess importance of each characteristic "not very important," "important," and "very important."
    "how_would_you_rate_the_cultural_attractions_of_the_district",
    "how_important_is_the_price_of_goods_and_services_available",
    "how_important_is_the_infrastructure_in_the_district",
    "how_important_is_the_cleanliness_of_the_district",
    "how_important_is_the_friendliness_of_the_district",
    "how_important_is_the_range_of_goods_and_services_available",
    "how_important_is_the_safety_of_the_district",
    "age", -- Respondents were asked their age.
    "what_would_you_keep_about_the_district", -- This open-answer response let respondents share what they would keep about the district.
    "ranking_of_bars", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_coffee_shops", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_barbers_hair_salons", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "how_long_is_your_average_visit_outside_of_work_to_district", -- Respondents shared how long their average visit was to the district, excluding work.
    "ranking_of_specialty_retail", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_office_supply_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "ranking_of_hardware_stores", -- Respondents were asked to rank the current business type offerings as "good," "fair," and "poor."
    "do_you_want_more_barbers_hair_salons", -- Respondents answered yes, they wanted more of this business, or no, they did not want more of this business.
    "do_you_want_more_coffee_shops",
    "do_you_want_more_convenience_stores",
    "do_you_want_more_grocery_stores",
    "do_you_want_more_florists",
    "how_many_times_a_month_do_you_come_to_district_for_dining_enter", -- * Inman and Alewife grouped the dining and entertainment questions together, whereas previous surveys had separated them.
    "how_important_is_the_quality_of_goods_and_services_available",
    "how_would_you_rate_the_safety_of_the_district",
    "how_would_you_rate_the_attractiveness_of_the_district",
    "how_would_you_rate_the_outdoor_activities_and_nightlife_in_the_",
    "do_you_want_more_farmer_s_markets",
    "how_important_is_the_availability_of_outdoor_activities_and_nig",
    "how_important_is_access_to_public_transit",
    "do_you_want_more_office_supply_stores",
    "do_you_want_more_restaurants_take_out",
    "how_important_is_the_attractiveness_of_the_district",
    "how_many_times_a_month_do_you_come_to_district_for_entertainmen",
    "do_you_want_more_accessory_stores_jewelry_shoes",
    "do_you_want_more_sporting_goods_stores",
    "how_would_you_rate_the_price_of_goods_and_services_available",
    "how_would_you_rate_the_presence_of_independent_businesses_in_th",
    "do_you_want_more_apparel_clothing_stores",
    "do_you_want_more_bars",
    "do_you_want_more_dry_cleaners_tailors",
    "do_you_want_more_home_goods_stores",
    "how_would_you_rate_the_cleanliness_of_the_district",
    "how_would_you_rate_the_infrastructure_of_the_district",
    "do_you_want_more_food_trucks",
    "how_would_you_rate_the_business_hours_of_the_district",
    "how_important_is_the_presence_of_independent_businesses"
FROM
    "cambridgema-gov/commercial-district-customer-intercept-survey-ibuz-brbz:latest"."commercial_district_customer_intercept_survey"
LIMIT 100;

Connecting to the DDN is easy. All you need is an existing SQL client that can connect to Postgres. As long as you have a SQL client ready, you'll be able to query cambridgema-gov/commercial-district-customer-intercept-survey-ibuz-brbz with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.cambridgema.gov. When you querycambridgema-gov/commercial-district-customer-intercept-survey-ibuz-brbz:latest on the DDN, we "mount" the repository using the socrata mount handler. The mount handler proxies your SQL query to the upstream data source, translating it from SQL to the relevant language (in this case SoQL).

We also cache query responses on the DDN, but we run the DDN on multiple nodes so a CACHE_HIT is only guaranteed for subsequent queries that land on the same node.

Query Your Local Engine

Install Splitgraph Locally
bash -c "$(curl -sL https://github.com/splitgraph/splitgraph/releases/latest/download/install.sh)"
 

Read the installation docs.

Splitgraph Cloud is built around Splitgraph Core (GitHub), which includes a local Splitgraph Engine packaged as a Docker image. Splitgraph Cloud is basically a scaled-up version of that local Engine. When you query the Data Delivery Network or the REST API, we mount the relevant datasets in an Engine on our servers and execute your query on it.

It's possible to run this engine locally. You'll need a Mac, Windows or Linux system to install sgr, and a Docker installation to run the engine. You don't need to know how to actually use Docker; sgrcan manage the image, container and volume for you.

There are a few ways to ingest data into the local engine.

For external repositories (like this repository), the Splitgraph Engine can "mount" upstream data sources by using sgr mount. This feature is built around Postgres Foreign Data Wrappers (FDW). You can write custom "mount handlers" for any upstream data source. For an example, we blogged about making a custom mount handler for HackerNews stories.

For hosted datasets, where the author has pushed Splitgraph Images to the repository, you can "clone" and/or "checkout" the data using sgr cloneand sgr checkout.

Mounting Data

This repository is an external repository. It's not hosted by Splitgraph. It is hosted by data.cambridgema.gov, and Splitgraph indexes it. This means it is not an actual Splitgraph image, so you cannot use sgr clone to get the data. Instead, you can use the socrata adapter with the sgr mount command. Then, if you want, you can import the data and turn it into a Splitgraph image that others can clone.

First, install Splitgraph if you haven't already.

Mount the table with sgr mount

sgr mount socrata \
  "cambridgema-gov/commercial-district-customer-intercept-survey-ibuz-brbz" \
  --handler-options '{
    "domain": "data.cambridgema.gov",
    "tables": {
        "commercial_district_customer_intercept_survey": "ibuz-brbz"
    }
}'

That's it! Now you can query the data in the mounted table like any other Postgres table.

Query the data with your existing tools

Once you've loaded the data into your local Splitgraph engine, you can query it with any of your existing tools. As far as they're concerned, cambridgema-gov/commercial-district-customer-intercept-survey-ibuz-brbz is just another Postgres schema.