{"database": "aphis", "private": false, "path": "/aphis", "size": 54714368, "tables": [{"name": "annual_reports", "columns": ["id", "cert_number", "report_year", "species", "total_animals", "animals_pain_cat_c", "animals_pain_cat_d", "animals_pain_cat_e"], "primary_keys": ["id"], "count": 0, "hidden": false, "fts_table": null, "foreign_keys": {"incoming": [], "outgoing": [{"other_table": "facilities", "column": "cert_number", "other_column": "cert_number"}]}, "private": false}, {"name": "enforcement_actions", "columns": ["id", "cert_number", "action_date", "action_type", "penalty_amount", "description", "outcome", "pdf_url", "pdf_local_path"], "primary_keys": ["id"], "count": 0, "hidden": false, "fts_table": null, "foreign_keys": {"incoming": [], "outgoing": [{"other_table": "facilities", "column": "cert_number", "other_column": "cert_number"}]}, "private": false}, {"name": "facilities", "columns": ["cert_number", "customer_number", "legal_name", "dba_name", "site_name", "site_address", "site_city", "site_state", "site_zip", "license_type", "status", "first_seen_date", "last_seen_date"], "primary_keys": ["cert_number"], "count": 15119, "hidden": false, "fts_table": null, "foreign_keys": {"incoming": [{"other_table": "inspections", "column": "cert_number", "other_column": "cert_number"}, {"other_table": "enforcement_actions", "column": "cert_number", "other_column": "cert_number"}, {"other_table": "teachable_moments", "column": "cert_number", "other_column": "cert_number"}, {"other_table": "annual_reports", "column": "cert_number", "other_column": "cert_number"}], "outgoing": []}, "private": false}, {"name": "inspections", "columns": ["id", "cert_number", "inspection_date", "inspection_type", "critical_count", "noncritical_count", "direct_count", "teachable_moment_count", "pdf_url", "pdf_local_path"], "primary_keys": ["id"], "count": 110400, "hidden": false, "fts_table": null, "foreign_keys": {"incoming": [], "outgoing": [{"other_table": "facilities", "column": "cert_number", "other_column": "cert_number"}]}, "private": false}, {"name": "teachable_moments", "columns": ["id", "cert_number", "inspection_date", "category", "description"], "primary_keys": ["id"], "count": 0, "hidden": false, "fts_table": null, "foreign_keys": {"incoming": [], "outgoing": [{"other_table": "facilities", "column": "cert_number", "other_column": "cert_number"}]}, "private": false}, {"name": "facilities_fts", "columns": ["legal_name", "dba_name", "site_name", "site_city", "site_state", "facilities_fts", "rank"], "primary_keys": [], "count": null, "hidden": true, "fts_table": "facilities_fts", "foreign_keys": {"incoming": [], "outgoing": []}, "private": false}, {"name": "facilities_fts_config", "columns": ["k", "v"], "primary_keys": ["k"], "count": 1, "hidden": true, "fts_table": null, "foreign_keys": {"incoming": [], "outgoing": []}, "private": false}, {"name": "facilities_fts_data", "columns": ["id", "block"], "primary_keys": ["id"], "count": 150, "hidden": true, "fts_table": null, "foreign_keys": {"incoming": [], "outgoing": []}, "private": false}, {"name": "facilities_fts_docsize", "columns": ["id", "sz"], "primary_keys": ["id"], "count": 15119, "hidden": true, "fts_table": null, "foreign_keys": {"incoming": [], "outgoing": []}, "private": false}, {"name": "facilities_fts_idx", "columns": ["segid", "term", "pgno"], "primary_keys": ["segid", "term"], "count": 146, "hidden": true, "fts_table": null, "foreign_keys": {"incoming": [], "outgoing": []}, "private": false}], "hidden_count": 5, "views": [], "queries": [{"title": "Search Facilities", "description": "Full-text search across facility names, cities, and states.", "sql": "SELECT f.cert_number, f.legal_name, f.dba_name, f.site_city, f.site_state, f.license_type, f.status, (SELECT COUNT(*) FROM inspections i WHERE i.cert_number = f.cert_number) AS inspection_count FROM facilities_fts JOIN facilities f ON f.rowid = facilities_fts.rowid WHERE facilities_fts MATCH :search ORDER BY rank LIMIT 200", "params": ["search"], "name": "search_facilities", "private": false}, {"title": "Inspection History for a Facility", "description": "View all inspections for a specific facility by certificate number (e.g., 43-A-0001).", "sql": "SELECT i.inspection_date, i.inspection_type, i.critical_count, i.noncritical_count, i.direct_count, i.teachable_moment_count, f.legal_name, f.site_city, f.site_state FROM inspections i JOIN facilities f ON f.cert_number = i.cert_number WHERE i.cert_number = :cert_number ORDER BY i.inspection_date DESC", "params": ["cert_number"], "name": "facility_inspections", "private": false}, {"title": "Facilities by State", "description": "Count of APHIS-licensed facilities in each state, broken down by license type.", "sql": "SELECT site_state, license_type, COUNT(*) AS facility_count FROM facilities WHERE site_state <> '' GROUP BY site_state, license_type ORDER BY site_state, facility_count DESC", "name": "facilities_by_state", "private": false}, {"title": "Recent Inspections", "description": "The most recent APHIS inspections across all facilities.", "sql": "SELECT i.inspection_date, i.cert_number, f.legal_name, f.site_city, f.site_state, i.inspection_type, i.critical_count, i.noncritical_count, i.direct_count FROM inspections i JOIN facilities f ON f.cert_number = i.cert_number ORDER BY i.inspection_date DESC LIMIT 200", "name": "recent_inspections", "private": false}, {"title": "Inspections with Critical Violations", "description": "Inspections where critical (serious) violations were found.", "sql": "SELECT i.inspection_date, i.cert_number, f.legal_name, f.site_city, f.site_state, f.license_type, i.critical_count, i.noncritical_count, i.direct_count FROM inspections i JOIN facilities f ON f.cert_number = i.cert_number WHERE i.critical_count > 0 ORDER BY i.inspection_date DESC LIMIT 200", "name": "critical_violations", "private": false}, {"title": "Facilities with Most Violations", "description": "Facilities ranked by total critical + noncritical + direct violations across all inspections.", "sql": "SELECT f.cert_number, f.legal_name, f.site_city, f.site_state, f.license_type, COUNT(*) AS total_inspections, SUM(i.critical_count) AS total_critical, SUM(i.noncritical_count) AS total_noncritical, SUM(i.direct_count) AS total_direct, SUM(i.critical_count) + SUM(i.noncritical_count) + SUM(i.direct_count) AS total_violations FROM inspections i JOIN facilities f ON f.cert_number = i.cert_number GROUP BY i.cert_number HAVING total_violations > 0 ORDER BY total_violations DESC LIMIT 100", "name": "worst_violators", "private": false}, {"title": "Facilities by License Type", "description": "Browse facilities filtered by license type (e.g., Class A - Breeder, Class C - Exhibitor, Class B - Dealer, Class R - Research Facility).", "sql": "SELECT cert_number, legal_name, dba_name, site_city, site_state, status FROM facilities WHERE license_type = :license_type ORDER BY legal_name LIMIT 500", "params": ["license_type"], "name": "facilities_by_type", "private": false}, {"title": "Inspection Trends by Year", "description": "Annual inspection counts with violation breakdowns.", "sql": "SELECT CAST(strftime('%Y', inspection_date) AS INTEGER) AS year, COUNT(*) AS inspections, SUM(CASE WHEN critical_count > 0 THEN 1 ELSE 0 END) AS with_critical, SUM(critical_count) AS total_critical, SUM(noncritical_count) AS total_noncritical, SUM(direct_count) AS total_direct FROM inspections WHERE inspection_date IS NOT NULL GROUP BY year ORDER BY year DESC", "name": "inspection_trends", "private": false}], "allow_execute_sql": true, "query_ms": 761.7128880228847, "source": "Federal Register API & Regulations.gov API", "source_url": "https://www.federalregister.gov/developers/api/v1", "license": "Public Domain (U.S. Government data)", "license_url": "https://www.regulations.gov/faq"}