cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza
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 dohmh_childcare_center_inspections table in this repository, by referencing it like:

"cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza:latest"."dohmh_childcare_center_inspections"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "zipcode", -- Zip code as per the address of the entity 
    "building", -- Building portion of the address. 
    "permitexp", -- This field represents the date a permit expired. All Group Child Care Centers (GDC) are permitted for 2 years and Camps for one. (All camps expire automatically on Sept. 15 of the year they opened). 
    "regulationsummary", -- Violation Description Language or null/blank for no violation in the inspection 
    "violationcategory", -- Violation Category - Public Health Hazard (violation needs to be fixed within 1 day),  Critical (Violation needs to be fixed within 2 weeks), General (Violation needs to be fixed in 30 days) or null/blank for no violation in the inspection 
    "childcaretype", -- Group Child Care (GCC) facilities are one of 2 program types: Preschool or Infant/Toddler. All GCC citywide statistics are calculated by type. 
    "facilitytype", -- Facility Type: FDC  - Family Day Care (State licensed),  GFDC - Group Family Day Care (State Licensed), SBCC - School Base Child Care (Licensed by NYS, DOE, Charter School or Regents), Camp, SMPG - Summer Program (NYS or NYC licensed), GDC - Group Day Care (NYC DOHMH Permitted), SACC - School Age Child Care (After School - State Licesned) 
    "averagepublichealthhazardiolationrate", -- Citywide average number of PHH (Public Health Hazard) violation categories over 3 years for a Child Care Type.  
    "bin", -- Building Identification Number assigned by the NYC  Department of Buildings to the building where the facility is located. If the last 6 digits are '0' then the address was not geocoded and the first digit designates the borough. 
    "violationavgratepercent", -- Citywide average violation rate calculated as percent of Initial Inspections that ended with a Critical or PHH (Public Health Hazrd) violation for a specific Child Care Type. Compare with Violation Rate to see if above or below it peers for a Child Care Type 
    "datepermitted", -- Estimated date that the site was orignally permitted, used to calculate the age of the program. See Actual field for additional information. 
    "healthcodesubsection", -- Health Code Sub Section 
    "dc_id", -- Unique DOHMH ID 
    "averagetotaleducationalworkers", -- Citywide average total number of Educational Staff in the program - includes teachers, assistant teachers and non administrative directors for a Child Care Type 
    "url", -- Website for the child care center.  
    "avgcriticalviolationrate", -- Citywide average number of Critical violation categories over 3 years for a Child Care Type.  
    "totaleducationalworkers", -- Current number of Educational Staff in the program, including teachers, assistant teachers, teacher directors and education directors. Note that staff data are updated only upon inspection and may be outdated. 
    "borough", -- Borough as per the address of the entity 
    "actual", -- Flag for correct (actual) date of original permit. Some programs pre-date the current DOHMH systems and do not have record of their original permit date. 'Y' indicates that the actual date is available, while 'N' indicates that the program was originally permitted sometime before the DatePermitted. 
    "status", -- SBCC: 'Active''; GDC & Camp: 'Permitted', 'Expired-In Renewal', 'Permit Suspended'; SMPG: 'Registered'. There are other statuses, such as Pending (prior to operational status) and OOB (Out of Business), but data are available only for currently operating child care facilities. 
    "programtype", -- Program Type - Infant Toddler, Preschool, After School, Preschool Camp, School Age Camp, All Age Camp 
    "violationratepercent", -- Percent of Initial Inspections that resulted in at least one Critical or Public Health Hazard (PHH) violation 
    "violationstatus", -- Violation Status - Open, Corrected or N/A. 
    "inspectiondate", -- Inspection Date 
    "publichealthhazardviolationrate", -- Percent of Public Health Hazard violations among all violations issued at initial inspections during the past 3 years. If the same violation is cited multiple times during one inspection, it is counted only once.  
    "agerange", -- This field represents the possible age range of children in the program. 
    "inspectionsummaryresult", -- The summary result of the inspection, based on the type of inspection and the number and types of violations. 
    "criticalviolationrate", -- Percent of Critical violations among all violations issued at initial inspections during the past 3 years. If the same violation is cited multiple times during one inspection, it is counted only once.  
    "street", -- Street portion of the address. 
    "centername", -- This is the Legal name of the Entity that permits the Child Care Center  
    "legalname", -- This is the name of the Child Care Center as known to the public (DBA) 
    "phone", -- Phone Number 
    "permitnumber", -- This is the Permit Number of a Child Care or a Camp. This number is not required for a School Based Child Care or After School Program. 
    "maximumcapacity" -- The maximum number of children the facility is allowed, based on the square footage of class and play rooms, the number of toilets and sinks, and overall estimates from the NYC Department of Buildings. Enrollment can be higher than the maximum capacity if there are part-time programs. 
FROM
    "cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza:latest"."dohmh_childcare_center_inspections"
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 cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.cityofnewyork.us. When you querycityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza: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.cityofnewyork.us, 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 \
  "cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza" \
  --handler-options '{
    "domain": "data.cityofnewyork.us",
    "tables": {
        "dohmh_childcare_center_inspections": "dsg6-ifza"
    }
}'

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, cityofnewyork-us/dohmh-childcare-center-inspections-dsg6-ifza is just another Postgres schema.