Quality check needed

#2
by lurndigital - opened

I investigated legal_clean.db. Short version: it is a real SQLite database with a law-oriented schema, but it is not currently a clean or trustworthy “global laws” database.

What It Is

  • SQLite 3 database, about 795 MB.
  • PRAGMA integrity_check returns ok, so the file itself is structurally readable.
  • Main populated tables:
    • jurisdictions: 237
    • legal_codes: 480
    • legal_sections: 101,367
    • legal_sources: 3
  • Empty tables:
    • criminal_laws
    • civil_laws
    • regulatory_laws
    • legal_procedures
    • source_updates

Big Findings

  • The schema looks intended for global legal data: jurisdictions, legal codes, sections, legal sources, FTS search tables, and specialized criminal/civil/regulatory tables.
  • The actual data is badly inconsistent:
    • legal_sections has 101,367 rows.
    • Only 427 of those rows join to an existing legal_codes.id.
    • 100,940 legal_sections rows are orphaned foreign-key references.
    • PRAGMA foreign_key_check reports 100,940 violations, all in legal_sections.
  • Most orphaned content appears to be U.S. Code material:
    • 99,922 orphaned rows use code_id = 1.
    • 99,921 of those point at https://uscode.house.gov/....
  • The legal_sources catalogue is not global:
    • Only 3 source records exist: United States, Canada, Germany.
    • Meanwhile legal_sections.source_url contains many more source URLs, so source metadata was not normalized into legal_sources.

Global Coverage Quality

  • jurisdictions contains broad-looking coverage: 192 countries, 41 states, 2 provinces, plus international/historical rows.
  • But jurisdiction normalization is weak:
    • 187 of 192 country jurisdiction codes are not ISO-style codes; they are names like afghanistan, bosniaandherzegovina, costarica.
    • State rows have blank parent_code.
    • There are duplicates/inconsistencies like us-california and us-ca.
  • Many linked “global” law records are one huge scraped document per country/state, not structured statute sections.
  • Some records are clearly scrape artifacts. Example: the linked French Penal Code row contains only: Just a moment... Enable JavaScript and cookies to continue.
  • I also found rows matching Access Denied, Page not found, and JavaScript/cookie challenge patterns.

Verdict
This database looks like a partially populated legal corpus, not a clean global laws database. It contains a lot of legal-looking text, especially U.S. Code material, and some country/state criminal or statutory text. But the current database is not reliable for legal retrieval because the main section table is mostly orphaned, the source catalogue is nearly empty, the jurisdiction model is inconsistent, and some content is scraper noise rather than law text.

A sensible next step is to quarantine the orphaned legal_sections, rebuild the code_id mappings from source_url and section metadata, normalize jurisdictions against ISO/country/state identifiers, remove scrape-error rows, then rebuild the FTS tables and rerun PRAGMA foreign_key_check until it returns clean.

Sign up or log in to comment