Free learning / 80-minute lab + optional query and snapshot workshops
Data 101: a document, a record and a searchable copy
Separate object storage, relational records and search. Run real local file reads, SQL queries and transactions, then catch a stale copy and an incomplete update.
No account needed. Use your own copy for writing and keep the original as a reference.
Engineering lab library / Run locally
Follow the data through a change
Predict seven results, inspect the actual rows and compare a successful update with a rollback. Then change the search and test a deliberately broken recovery.
Real local file reads and SQLite queries with fictional data. Search and identity are simplified; no model, cloud resource or network is used.
Search titles, outcomes and prerequisites, then narrow by runtime.
3 of 3 labs · All labs
Start here / Python 3.11+ · Standard library
SQL values, scope and search meaning
Compare interpolation, bound values, a missing workspace condition and literal versus wildcard matching using actual returned rows.
Python 3.11+ with SQLite · In-memory fictional rows · No packages or network
Python 3.11+ · Standard library
Read snapshots across two connections
Observe a mixed read, a coherent older snapshot, deferred BEGIN and an uncommitted writer; hand over the exact read boundary.
Python 3.11+ with SQLite WAL · Temporary local database · No packages or network
Python 3.11+ · Standard library
Document, record and search lifecycle
Compare source and copy changes, then inspect transaction boundaries and actual foreign-key enforcement.
Python 3.11+ with SQLite · Standard library · No model or cloud
A teammate asks, “Can we put all the client’s documents in a vector database and let the agent handle it?” Start with a simpler question: which information are we trying to keep, and what question must it answer? Finding a procedure, updating a ticket and checking whether a procedure is current are different jobs.
This original 80-minute lesson follows Field Desk, a fictional maintenance assistant. Read the definitions, explore the visual, then run seven local cases, three transaction-boundary comparisons and four foreign-key experiments. You will keep a data map, actual query results and isolated changed-copy experiments. No model or cloud account is needed.
1. Name the job before choosing a product
Object storage keeps named objects: bytes, a key and metadata. A procedure PDF, image or JSON document can be an object. A relational database stores records in tables with named columns. A search index is a representation prepared to help find material. These are responsibilities, not a requirement to buy three separate products. A database may provide search as well as record queries.
Think of a shared drive with manuals, a spreadsheet tracking tickets and a catalog that helps find a manual. The analogy gets you started. A database also provides queries, constraints and transactions; a cloud object service has its own versioning and access behavior. The catalog is a copy, so it can lag behind a changed or deleted manual.
A row is one record. A primary key identifies it, such as ticket T-104. SQL, Structured Query Language, expresses queries and changes to relational data; SQLite and PostgreSQL are database software. A transaction groups database operations so they can commit together or be rolled back together. It does not automatically include a separate file, object service or search service.
An authoritative source owns a particular fact. In this example, procedure P-17 owns procedure content, while the ticket table owns T-104’s status. Ingestion builds the searchable copy from the source. Provenance keeps the source ID, revision and origin with that copy. A plausible match is a candidate; it is not proof of current content, permission or a correct answer.
An FDE needs this map before connecting customer data to an agent. If a user asks whether a ticket is open, query its current record. If they need the review procedure, find an eligible passage and check it before supplying it to a model. The model should not guess either the current ticket state or the caller’s permission.
UNDERSTAND THE SYSTEM
One assistant, three different data jobs
Follow a fictional document, ticket and searchable copy. Each experiment starts fresh. The downloadable lab performs real local file reads and SQL operations; the visual summarizes those cases without running a cloud service or model.
Watch one example, step by step.
Read the full worked example
- 01Separate the jobs
Read the ticket record to find its status. Read the procedure object for its content. Search the derived copy for a candidate, then check it before building model context. These roles can share a database; they do not require three vendors.
Two questions: Ticket: is T-104 open? Search: which passage matches?
- 02Catch the stale copy
P-17 is at revision 2. Search still returns revision 1. The local application excludes it even though its text matches the query. Changing a source did not automatically refresh the derived copy.
STALE-COPY: 1 candidate · 0 context entries
- 03Refresh, then recheck
The lab refreshes the search row from the current source. Source ID, scope, revision and text now agree. One entry reaches the context list; nothing calls a model. A later scope change still requires a new access check.
CURRENT-COPY: 1 candidate · 1 context entry · 0 model calls
- 04Commit related ticket facts
A fresh case begins a database transaction, updates T-104 and inserts its event. Commit retains both. The separate procedure file and its searchable copy stay unchanged; the ticket status is not a fact to infer from a procedure.
RECORD-UPDATE: Resolved ticket · 1 event · procedure unchanged
- 05Roll back an incomplete update
In another fresh case, a deliberate exception occurs after the ticket update and before event insertion. An explicit SQLite rollback leaves the ticket open with no event. The SQL transaction does not cover an external file or cloud service.
RECORD-ROLLBACK: Open ticket · 0 events · procedure unchanged
- 06Exclude a copy after deletion
A fresh case removes its temporary source file but leaves the search row. One candidate still matches; the current-source check excludes it. Derived-copy cleanup, caches, backups and retention need their own explicit handling.
SOURCE-DELETED: Source absent · 1 search row · 0 context entries
Read the connections in plain English
- 01Procedure document → Searchable copy
Ingestion creates a derived search representation. An update or deletion must be propagated deliberately; the copy can lag behind the source.
- 02Assistant app → Ticket record
The app issues a scoped query for ticket T-104. The database owns that ticket's current status.
- 03Assistant app → Searchable copy
The app searches only the caller's permitted source scope. Results are candidates, not established facts.
- 04Searchable copy → Evidence check
The candidate carries its source ID and revision into an application check. A plausible match is not enough.
- 05Procedure document → Evidence check
This illustration's trusted source metadata establishes the current revision and access. Existence, freshness and permission all matter before model context is built.
- 06Evidence check → Model context
Admit only a current, permitted candidate. Exclude stale, denied or deleted-source entries; report missing evidence when nothing usable remains.
Check your understanding: If the procedure is deleted, can the remaining index entry still be used?
No. A leftover search copy is not evidence that its source still exists or that access remains valid. Exclude it from new model context, remove derived entries through the deletion process, and handle caches and backups under the explicit retention policy. Deleting one copy is not proof that all copies are gone.
2. Predict what changes in seven cases
P-17 is a JSON document at revision 2. T-104 is an open ticket that references it. A search table initially contains revision 1. The program’s training scope is a supplied trusted-context fixture, not a real login. Each case starts from a fresh temporary source file and fresh SQLite database; changes do not carry into the next case.
| Case | Ticket / event rows | Search and source | Evidence result |
|---|---|---|---|
stale-copy | open / 0 | Search revision 1; source revision 2 | Exclude: stale revision |
current-copy | open / 0 | Copy refreshed from revision 2 | One usable context entry |
record-update | resolved / 1 | Source and search content unchanged | One usable context entry |
record-rollback | open / 0 | Exception before event insertion; explicit rollback | One usable context entry; ticket work did not commit |
access-revoked | open / 0 | Copy still matches; current source is restricted | Exclude: denied access |
source-deleted | open / 0 | Temporary source removed; search row remains | Exclude: missing source |
modified-copy | open / 0 | Revision numbers match; copied text differs | Exclude: content mismatch |
On a narrow screen, scroll the table sideways. Before each run, predict the ticket state, event count and context-entry count. A permitted procedure is not proof that a ticket update committed; a successful ticket update is not permission to use a procedure.
3. Run the local lab
Download fde-data-foundations.py and keep it beside your working copy. Use Python 3.11 or newer with its standard-library SQLite module. If a distributor omitted SQLite, use a Python installation that includes it. No package installation is required.
python3 --version
python3 -c "import sqlite3; print(sqlite3.sqlite_version)"
python3 fde-data-foundations.py compare
python3 fde-data-foundations.py record-update
python3 fde-data-foundations.py record-rollback
python3 fde-data-foundations.py source-deletedThe program actually writes and reads a JSON file in its own temporary directory, executes SQLite queries and commits or rolls back a transaction. The directory is removed after each case. The database is in memory. It makes no network requests and does not touch your documents, run a model, verify an identity or provision vendor storage.
The search copy is a real SQLite row built from the source. LIKE performs a small text-pattern lookup; it is not vector search, semantic ranking or a production search index. Every baseline case finds one candidate. Only current-copy, record-update and record-rollback admit one context entry. The other four admit none. All cases report zero model calls.
In source-deleted, compare source_exists: false, index_rows: 1 and the empty context list. The copy really remains in this local database until cleanup. That is why removing a source alone cannot establish that all derived copies are gone.
4. Read the query and the transaction
The ticket lookup is short enough to read as a sentence:
SELECT ticket_id, status, procedure_id
FROM tickets
WHERE ticket_id = ? AND scope = ?SELECT chooses columns, FROM names the table and WHERE filters rows. The question marks are parameter placeholders; Python passes values separately from SQL text. Both ticket identity and the supplied trusted scope constrain this query. Missing or invisible data returns no row, not a guessed ticket status. This one path does not establish complete tenant isolation.
The search query uses the ticket’s procedure ID, the derived row’s scope and the query text. Before admitting the result, inspect loads the current source and checks existence, current scope, source ID, revision and content. A stale scope in the copy cannot overrule the source’s current restriction. Comparing full text works for this tiny whole-document example; real chunk pipelines need their own trusted provenance and integrity design.
update_ticket executes BEGIN, changes the ticket and inserts an event before COMMIT. The success case leaves a resolved ticket and one event. The failure case raises an exception after the update but before the event insert, then explicitly executes ROLLBACK. The query afterwards sees an open ticket and no event. The failure is deliberately injected; the database operations and rollback are real.
The original record-update and record-rollback cases never write P-17 during the ticket transaction. Its unchanged content is a separate observation, not proof that SQLite can undo object writes. Likewise, an event row is an ordinary row here, not a tamper-proof audit log. This exercise does not test process crashes, disk durability, concurrent changes or a cloud service’s transaction behavior.
4a. Observe a file write outside the transaction
Now change a second resource during the operation. A database transaction covers participating database work. A separate JSON write is a filesystem operation: putting that Python call between BEGIN and ROLLBACK does not make SQLite responsible for undoing it.
The new cases write P-17 at revision 3 immediately after the permitted ticket update and before the injected failure or event insert. Each case starts fresh. Predict all three results, then run:
python3 fde-data-foundations.py boundary| Independent case | Ticket / events | Source / search revision | Context entries |
|---|---|---|---|
record-rollback | open / 0 | 2 / 2 | 1 |
external-write-rollback | open / 0 | 3 / 2 | 0 |
external-write-commit | resolved / 1 | 3 / 2 | 0 |
Read source_text, the actual file text in the boundary report. Both added cases read “Revision 3: attach the review note and decision to the ticket.” The explicit SQL rollback restores the ticket and event state, but that file change remains. The successful control commits the ticket and event; it still does not refresh search. Both added cases find one candidate and exclude it as stale-revision.
The search row is in the same SQLite database. It remains revision 2 because these operations do not update it, not because search rows are forbidden from joining a transaction. The JSON file is the separate resource. Distinguish a missing refresh from a resource outside the database boundary.
Controlled experiment: in a fresh copy, replace only save_source(source_path, EXTERNAL_UPDATE) with pass. Keep the original. Run external-write-rollback in the edited copy. Predict open/zero events, source and copy revision 2, and one current context entry. Run external-write-commit as a second control: the SQL result remains resolved/one event while the file is unchanged. Restore the original afterwards. Disabling one file call isolates what caused the stale copy.
This is a real local comparison, not a distributed transaction or a crash test. A successful sequence cannot prove that several resources always change together. Moving the file write after COMMIT would change the failure window; it would not eliminate it. Before deploying across services, define pending work, operation identity, safe repeated delivery and reconciliation. An outbox can record intent with local data; this lab does not implement one or establish exactly-once remote effects.
UNDERSTAND THE SYSTEM
A database rollback does not rewind the file.
Compare final observations from three independent local experiments. Each starts with source revision 2, a current search copy and an open ticket. The Python program executes real SQLite transactions and temporary JSON writes. The arrows distinguish responsibilities; this visual does not execute code or model a cloud transaction.
Watch one example, step by step.
Read the full worked example
- 01Roll back only database work
The ordinary failure case never writes the file. Rollback leaves an open ticket and zero events; source and copy both remain revision 2. One current context entry is eligible, even though the ticket update did not commit.
LOCAL EXECUTION · DATABASE ONLY: Ticket open · events 0 · source 2 · copy 2 · context 1
- 02Write the file, then roll back
The added case writes source revision 3 before raising the supplied error. SQL rollback restores the ticket and event state, but the actual JSON read still returns revision 3. The unrefreshed revision-2 search row is excluded. The exception did not reverse both resources.
LOCAL EXECUTION · EXTERNAL WRITE: Ticket open · events 0 · source 3 · copy 2 · context 0
- 03Commit without refreshing search
The control writes revision 3, inserts the event and commits the SQL transaction. The ticket is resolved with one event. Search still holds revision 2 because no refresh ran, so context remains empty. One successful sequence is not proof of atomic file/database coordination.
LOCAL EXECUTION · COMMIT CONTROL: Ticket resolved · events 1 · source 3 · copy 2 · context 0
Read the connections in plain English
- 01Application operation → SQLite transaction
Update the ticket, then insert the event or explicitly roll back after the injected failure.
- 02SQLite transaction → Read the actual rows
Query the actual ticket and event rows after the transaction ends.
- 03Application operation → Separate JSON file
The optional JSON write is an independent filesystem operation.
- 04Separate JSON file → Check before context
Read the actual file revision; this is not part of the database rollback.
- 05Search row → Check before context
Read the unchanged search candidate and check it against the source.
Check your understanding: Is the stale search row outside the transaction because it is an index?
No. It is a row in the same SQLite database and could be refreshed in the transaction. This code did not update it. The JSON file is the operation outside the database boundary; separate the resource boundary from a missing update.
4b. Test the database relationship
A foreign key links a child value to a parent key. Our child table is ticket_events; its ticket_id must reference a row in tickets. The column is also NOT NULL, so this schema does not allow an event with no ticket identifier. A relationship written in the schema is only part of the evidence. Check how the writer’s connection enforces it and what is already stored.
Use the same downloaded file for this 15-minute extension. No new packages, network services or database account are needed. Predict the four outcomes, then run:
python3 fde-data-foundations.py constraints| Independent case | Enforcement at insert → afterward | Stored events | Error | Relationship findings |
|---|---|---|---|---|
existing-parent | 1 → 1 | 1, referring to T-104 | None | 0 |
missing-parent-enforced | 1 → 1 | 0 | IntegrityError | 0 |
missing-parent-unenforced | 0 → 0 | 1, referring to absent T-missing | None | 1 |
enable-after-orphan | 0 → 1 | The same orphan remains | None | 1 |
Each case starts with a fresh in-memory database and the existing T-104 ticket. The insert and SQL reads are real. In the last case, the program commits the orphan before enabling enforcement, confirms no transaction is active, reads back the setting and checks the same stored event again. A committed row in this scratch database is not evidence of durability across a process or host loss.
Read foreign_keys_before_insert, foreign_keys_after, inserted_rows, persisted_events, error_class and foreign_key_check. The last array contains SQLite’s actual findings: child table, row ID, parent table and foreign-key index. It is empty when this relationship has no violations; it is not an audit of every business rule. persisted_events_before_enable in the last case lets you compare the event before and after the configuration change.
Two different commands answer different questions:
PRAGMA foreign_keys; -- Is this connection enforcing foreign keys now?
PRAGMA foreign_key_check; -- Which declared relationships are violated in stored rows?SQLite’s enforcement setting belongs to the connection. Establish and verify it before transactional work; changing it inside an active transaction has no effect. Do not assume an import utility or background writer inherits another connection’s setting. These are SQLite-specific controls, not commands to paste into PostgreSQL or a managed cloud database. The checked primary references are SQLite foreign-key support and foreignkeycheck (25 October 2026).
Change the parent, not the protection. Preserve the original file. In a separate copy, change only CONSTRAINT_PARENT_ID = "T-missing" to CONSTRAINT_PARENT_ID = "T-104", then run constraints again. All four inserts now refer to an existing ticket, so all four can succeed without a foreign-key finding. The third case still has enforcement off. Correct input can hide an inactive guard; retain the original invalid-input experiment too.
The ticket stays open in every case. A valid relationship does not prove that an event’s meaning agrees with ticket status, that its author had permission, or that a source document is current. Likewise, enabling a guard does not invent missing parents or repair historical rows. In a real receiving system, identify the authoritative record and owner, agree an appropriate correction or quarantine, and recheck after an authorized repair. Do not delete history or fabricate a parent just to obtain an empty findings array.
UNDERSTAND THE SYSTEM
A stored event can still point to a missing ticket
Compare four real SQLite experiments from the Data 101 download. A declared relationship, the connection's enforcement setting and the stored rows are separate observations. The browser replays the supplied examples; run constraints to obtain your own results.
Watch one example, step by step.
Read the full worked example
- 01Insert an event for T-104
Foreign-key enforcement is on. T-104 exists, so the event insert succeeds and the later relationship check reports no violation. Ticket status remains open: the foreign key requires a parent, not a particular business state.
EXISTING PARENT: Enforcement 1 · events 1 · findings 0
- 02Reject a missing parent
Enforcement is on, but T-missing has no parent row. The actual INSERT raises IntegrityError. No child is stored, and the relationship check has no orphan to report. The valid T-104 row is unchanged.
MISSING PARENT: Enforcement 1 · events 0 · findings 0
- 03Observe the disabled check
This independent case explicitly disables foreign-key enforcement before inserting. The schema still declares REFERENCES, but the insert succeeds and stores one orphan. foreign_key_check reports the missing parent rather than relying on the successful operation label.
ENFORCEMENT OFF: Enforcement 0 · events 1 · findings 1
- 04Enable without repairing history
The orphan is inserted and committed with enforcement off. With no transaction active, the program enables enforcement and reads back 1. The same event remains, and foreign_key_check still reports one violation. Turning on a guard for later writes did not repair an earlier record.
CHECK EXISTING ROWS: Enforcement 1 · events 1 · findings 1
Read the connections in plain English
- 01Parent: tickets → Child: ticket_events
Compare the requested parent with the row identified by the declared key.
- 02Child: ticket_events → Stored event rows
Observe whether SQLite accepts or rejects the child row under the actual connection setting.
- 03Stored event rows → Relationship check
Check the stored relationship separately from the INSERT result and current configuration.
Check your understanding: The connection reports foreign_keys = 1. Does that prove every existing relationship is valid?
No. Inspect existing rows with the relevant check. The final case has enforcement enabled and still contains an earlier orphan. Decide any repair from authoritative business evidence; do not invent a parent or delete history just to clear the report.
4c. Compare reads across a commit
This optional 25-minute workshop asks a different question: can two individually successful reads be assembled into a state that never existed? A writer can update related rows atomically while a reader still combines facts from different moments. A snapshot is the database view held for a read transaction. Consistency asks whether the facts belong together; freshness asks whether they are recent enough for the task.
Download the two-connection read lab. It requires Python 3.11+ with SQLite supporting write-ahead logging (WAL). It creates and removes its own temporary local database, uses no packages or network, and never opens an existing database. Check python3 --version first; if it is older than 3.11, use your installed python3.11 or newer executable in each command. Run on a local filesystem. The program verifies WAL rather than silently substituting another mode.
The synthetic starting state is ticket T-104 requiring P-17 revision 1, whose body is “Use the green form.” A second connection changes both rows in one transaction to revision 2 and “Use the blue form.” These are invented maintenance instructions, not client records. The database stores only 1/1 before that commit and 2/2 afterward. The program deliberately orders the calls in one process across two independent connections; it does not rely on sleep or a race winning by chance.
Before running, each person predicts the ticket requirement, procedure revision and final fresh pair. One participant runs the lab and another receives the output. Retain individual predictions even if the group agrees.
python3 fde-read-snapshots.py compare
python3 fde-read-snapshots.py case snapshot
python3 fde-read-snapshots.py case begin-onlyUNDERSTAND THE SYSTEM
Two successful reads can tell one impossible story
Four independent SQLite WAL experiments use two real connections. These frames explain the supplied ordering; the browser does not run a database. Predict the pair, then run the download and inspect its actual rows.
Watch one example, step by step.
Read the full worked example
- 01Separate reads: a mixed pair
The ticket SELECT finishes before B commits. The later procedure SELECT sees revision 2. Both values came from committed rows, but A combines 1/2. B never stored that pair; its atomic update did not group A's separate reads.
SEPARATE READS: Assembled 1/2 · final database 2/2
- 02One snapshot: coherent, older evidence
A begins a transaction and reads the ticket before B commits. Its procedure read remains at revision 1. Ending that read transaction and reading again reveals 2/2. The first packet is internally coherent and older than the final committed fixture.
HELD SNAPSHOT: Assembled 1/1 · fresh reread 2/2
- 03BEGIN alone: no read yet
In this independent case A issues deferred BEGIN without reading. B commits 2/2 before A's first SELECT. A then reads 2/2. Locate the first database read rather than using the earlier BEGIN timestamp as the evidence boundary.
FIRST READ MATTERS: Assembled 2/2 · final database 2/2
- 04Uncommitted changes: not the reader's facts
B changes both rows but has not committed. A reads 1/1. B then rolls back, leaving a final fresh pair of 1/1. A successful UPDATE in B was not a committed change visible to A.
WRITER ROLLS BACK: Assembled 1/1 · final database 1/1
Read the connections in plain English
- 01Reader: ticket → Writer: both rows
The program places the writer between the two reads. This is a controlled interleaving, not a timing benchmark.
- 02Writer: both rows → Reader: procedure
A commit makes the replacement available to a new read transaction; a held snapshot still sees its earlier rows.
- 03Reader: procedure → Assembled evidence
Use the two actual SELECT results, not a success message, to assemble the packet.
Check your understanding: The snapshot has a matching ticket and procedure. May the receiving team treat it as current approval?
No. The snapshot case returns 1/1 while a fresh read returns 2/2. Internal consistency, freshness and authorization answer different questions. Name when evidence must be revalidated and who can authorize the actual action.
4d. Locate the read boundary in four experiments
Each case starts from a fresh database. Read the actual query results and timeline before using any summary label.
| Case | Controlled order | Reader's assembled pair | Fresh pair after writer finishes |
|---|---|---|---|
separate-reads | Read ticket; finish statement; writer commits both rows; read procedure | 1 / 2: mismatched | 2 / 2 |
snapshot | BEGIN; read ticket; writer commits; read procedure in the same read transaction | 1 / 1: coherent and older | 2 / 2 |
begin-only | Deferred BEGIN; writer commits; first reader SELECT; second reader SELECT | 2 / 2 | 2 / 2 |
uncommitted | Writer changes both rows without committing; reader reads; writer rolls back | 1 / 1 | 1 / 1 |
In separate-reads, neither SELECT read uncommitted data. The application combined the old ticket with the new procedure. The writer's successful transaction cannot retroactively group those separate reads. Return that mixed packet for reconstruction before relying on its instructions.
In snapshot, the reader sees a coherent old pair while the writer commits a new pair. A fresh read after ending the transaction sees 2/2. The old pair is not corrupted, but a receiving task may require a newer view. Record the read boundary and the task's freshness requirement; do not silently call matching revisions “current.”
For SQLite's deferred BEGIN, the first database read establishes the view used here. begin-only deliberately places that first read after the writer commits. uncommitted supplies the other control: writer-local success is not a commit visible to the reader. WAL permits the reader and writer transactions in this experiment to overlap. Different engines and isolation settings need their own tests; this is not a generic recipe for PostgreSQL or a distributed snapshot over APIs.
Controlled change: keep the original file, then change only UPDATE_REVISION = 2 to UPDATE_REVISION = 3 in a copy. Predict the four assembled pairs and final pairs before running compare. Which outcomes change, and which boundary explanations stay the same? Keep both outputs and the diff. The baseline self-test belongs to the unchanged file; passing it is not the goal of the altered experiment.
Transfer challenge: a procedure and its access policy live in different services. This SQLite snapshot does not include either remote response. Identify which read must be current at the intended action, which owner defines that requirement and what the application does if it cannot establish it. A later write also needs a concurrency contract; a previous consistent read is not a lock on future facts.
4e. Hand over a read contract
The builder supplies the exact file or changed copy, command and output. The receiver chooses a case and finds the two SELECT results, the writer's commit or rollback, and the final fresh pair without the builder narrating. The pod lead records the unresolved freshness decision and its actual receiving owner. A database owner verifies the receiving engine and transaction settings; the business owner defines when the facts must still hold. Neither role inherits the other's decision.
Keep this individual note with your practice record:
Candidate / command / case / output location:
My prediction / actual rows I inspected:
First read / second read / writer commit or rollback:
Assembled pair / final fresh pair / why they differ:
Read boundary and receiving freshness requirement:
Decision: return mixed evidence | receive for a stated purpose | pending
Next owner / specific unresolved check / next evidence:
My contribution / help received / changed-copy result:A receiver who can explain 1/1 versus 2/2 has demonstrated this bounded interpretation, not permission to use real client data or independent deployment readiness. Repeat the missed receiving step with another case and preserve the first attempt.
The SQLite behavior is grounded in isolation between connections and deferred transactions, checked 26 October 2026. The fictional record, ordering, local exercise and receiving task are original LockedIn Labs material.
5. Change the search and break the rollback
Make two separate copies of the Python file. Keep the original and its output.
Experiment A: a search miss is not a missing source. Replace QUERY = "review" with QUERY = "renewal". Run current-copy in that copy. Expect matching_candidates: 0, evidence_reason: "no-search-match" and empty context. The source still exists and index_rows is still 1. Explain why “we found nothing using this query” is different from “there is no procedure.” Do not change the document merely to make a test pass; propose a fresh query and a new test case.
Experiment B: inspect state instead of trusting the status label. In a separate disposable copy, deliberately replace db.execute("ROLLBACK") with db.execute("COMMIT"). Run record-rollback. The ticket is now resolved with zero event rows. The returned transaction label still says rolled-back because you have broken the implementation without changing its label. Read the actual rows: the operation left partial business state. Restore the original file afterwards; this is a local fault experiment, not a recovery recommendation.
Write why a receiving engineer needs observed data as well as an application message. Propose a check that compares the ticket and event after failure. Do not infer that a correct local rollback covers an external object store, a send operation or recovery after power loss.
6. Connect the pattern to your cloud
| Responsibility | Google Cloud example | AWS example | Azure example |
|---|---|---|---|
| Keep procedure objects | Cloud Storage | Amazon S3 | Blob Storage |
| Operate a relational database | Cloud SQL | Amazon RDS | Azure SQL Database |
These examples identify roles, not interchangeable APIs or a complete architecture. Choose a search service or database index from the workload’s query, update, access and operational requirements. Azure AI Search is one example of a separate search service. The local SQLite exercise is not a provisioned version of any of these products.
Prepare one provider-specific data map: source owner, location, read identity, revision scheme, update trigger, derived copies, deletion path, retention rules and an observation to verify each boundary. An object service’s consistency guarantee does not make your separately maintained search copy current. Handle indexing failures and reconcile changes deliberately. Cache invalidation, revocation races, backups and retention remain separate operating concerns.
Continue with the protected Data 101 lesson for Explain, Debug and Design rehearsals, then apply the map to a cloud:
You need existing training access for those lessons. This guide and its local exercise stay free. For the next conceptual step, open RAG: from documents to model context in the agent engineering course. Retrieval-augmented generation connects eligible evidence to a model call; it does not replace these storage responsibilities.
7. Keep a data map another engineer can use
Keep the seven original predictions and outputs, the three boundary comparisons, the four relationship observations, isolated changed-copy outputs and a diagram identifying which store owns each fact. Add one update and deletion route for each copy. Ask a colleague to explain the rollback case and the search miss without your narration.
A useful handover says, “T-104’s status is in the ticket table; P-17 owns the procedure; search supplies candidates checked against the current source. Here is the observed failure behavior, and here are the cloud and concurrency checks we have not performed.” It does not claim that a diagram or a local exercise certifies a deployment.
For the implementation concepts, see Python SQLite and SQLite transactions, checked on 25 October 2026. Object and search references checked on 21 October 2026: Cloud Storage, Amazon S3 and Azure AI Search indexes. Related service references: Cloud SQL, Amazon RDS, Blob Storage and Azure SQL Database.
8. Separate SQL values, workspace scope and search meaning
This optional 25-minute workshop makes the query boundary observable. A parameter supplies a value separately from the SQL statement. A predicate is a condition deciding which rows qualify. SQL injection happens when supplied text changes the statement's syntax. Correctly bound values still need the right predicates and match rules.
Download the query-boundary lab. Use Python 3.11+ with its standard-library SQLite module. Check python3 --version; if it is older than 3.11, use your installed python3.11 or newer command below. Each case creates a fresh in-memory database with five fictional maintenance records, performs the comparisons and closes the connection. It needs no packages, network, files or credentials. The deliberately unsafe statements are isolated teaching comparisons; the program accepts only named cases, not arbitrary SQL or an existing database.
| Workspace | ID | Title |
|---|---|---|
| north | N-1 | Operator's guide |
| north | N-2 | Pump 100% checklist |
| north | N-3 | Shared handbook |
| south | S-1 | Shared handbook |
| south | S-2 | South pump notes |
The intended exact lookup is a title in North. The intended substring search finds a literal character in a North title. North is supplied by the fixture; no login or authorization service is implemented. In a real system, resolve workspace and permission from trusted server context before executing the appropriately scoped query.
SELECT workspace, id, title
FROM documents
WHERE workspace = :workspace AND title = :titlePython binds the values separately, for example {"workspace": "north", "title": "Operator's guide"}. Do not construct a new SQL string by inserting those values. Before running, predict the returned workspace/ID pairs or error for each comparison. One participant executes; another receives the output. Keep both predictions.
python3 --version
python3 fde-query-boundaries.py compare
python3 fde-query-boundaries.py case missing-scope
python3 fde-query-boundaries.py case wildcard-inputUNDERSTAND THE SYSTEM
A bound value is not the whole query contract
Four independent SQLite comparisons separate syntax, workspace scope and search meaning. These frames explain supplied examples; the browser does not execute SQL. Run the Python companion to inspect actual statements, parameters and returned rows.
Watch one example, step by step.
Read the full worked example
- 01An ordinary apostrophe
Operator's guide is legitimate title text. Naive interpolation breaks the SQL string and produces an error. Binding the same title returns north/N-1. Rejecting every apostrophe would reject valid data instead of repairing the syntax boundary.
VALUE AND SYNTAX: Interpolation: error · bound: 1 row
- 02Text changes the predicate
The fixed injected title changes the interpolated WHERE expression to include OR 1=1. It returns all five fictional rows, including South. The bound query treats the whole input as title text and returns zero. These local results expose a syntax defect; they do not establish complete authorization.
SQL INJECTION: Interpolated: 5 rows · bound: 0 rows
- 03A scope condition is missing
Both queries bind Shared handbook. The unscoped statement returns north/N-3 and south/S-1. Adding the workspace condition returns only north/N-3. Parameterization cannot insert a missing authorization relationship, and the supplied North value still needs a trusted source in a real application.
SCOPE IS SEPARATE: Unscoped: 2 rows · scoped: 1 row
- 04A bound pattern is still a pattern
Both queries bind their pattern and restrict North. Treating percent as a LIKE wildcard matches all three North titles. Escaping the supplied percent for the intended literal-substring contract matches only Pump 100% checklist. This broader match is pattern meaning, not injected SQL syntax.
MATCH MEANING: Pattern: 3 rows · literal: 1 row
Read the connections in plain English
- 01Supplied value → SQL and parameters
Compare the SQL text with the separately bound parameter; do not infer one from the other.
- 02SQL and parameters → Scope and meaning
Binding a value does not supply workspace scope or define literal matching.
- 03Scope and meaning → Actual returned rows
Locate the actual workspace, ID and title, or the error, in the executable output.
Check your understanding: Every value is bound. Does that establish a correctly scoped, literal search?
No. Inspect syntax separation, trusted scope and match meaning independently. The missing-scope case still returns two workspaces; the wildcard case still matches three North titles. A receiver needs the actual SQL, parameters and row identities, plus the real system's identity and authorization contract.
9. Explain four different query failures
| Case | First attempt | Compared attempt | Actual difference |
|---|---|---|---|
quoted-title | Insert Operator's guide into quoted SQL text | Bind the same exact title | SQL error versus north/N-1 |
predicate-injection | Insert the supplied syntax-changing title into SQL | Bind the entire input as a title | All five rows versus zero rows |
missing-scope | Bind Shared handbook, omit workspace predicate | Bind title and restrict workspace | north/N-3 plus south/S-1 versus north/N-3 |
wildcard-input | Bind a contains-pattern made from % | Escape the supplied character for literal matching, then bind | Three North rows versus north/N-2 |
The first case is ordinary valid data. Removing apostrophes from every title is not the repair: the bound query handles the legitimate title without converting its punctuation into SQL. In the injection case, inspect the actual statement containing OR 1=1 and the returned South rows. The bound comparison finds no title equal to the entire supplied text. Do not turn that single control into a claim that all reads are authorized.
The scope case uses parameters in both statements. The missing condition allows the other workspace's Shared handbook into the result. Binding does not know which rows the caller may read. A real data-access path also needs verified identity, action/resource policy and complete joins; a workspace equality alone is not a full permission model. Continue with the identity and record-permission lab for that relationship.
The last case also binds values in both attempts. SQLite LIKE assigns special meaning to % and _; parameterization does not remove that pattern meaning. Under the chosen literal-substring contract, escape the escape character first, then percent and underscore, and use the matching ESCAPE clause. The surrounding wildcards still mean “contains.” This is a specific SQLite search contract, not a generic sanitizer for SQL syntax or other engines. If the product intentionally offers wildcard search, document that different contract instead of silently changing it.
Controlled change: keep the original file. In an isolated copy change only ESCAPE_LIKE_INPUT = True to False. Predict the literal-search attempt before running compare. It now matches three North rows rather than one; binding and workspace scope remain present. The other cases retain their outcomes. Keep the diff and both outputs. The baseline self-test is expected to reject this changed copy.
Transfer challenge: a coding agent proposes a query using placeholders and calls it safe. Ask the receiver to identify the trusted scope source, selected columns, match semantics, allowed rows and a forbidden-row control. Parameter placeholders bind values; choosing table names, columns or ordering requires a separate constrained query design. The transfer challenge does not require access to an external or production database.
10. Receive the query with its evidence
The builder supplies the exact file, command, SQL and parameter report. The receiver locates every returned workspace/ID pair and explains which comparison changes syntax, scope or matching. The service owner confirms the real application's identity and access contract; the business owner confirms whether the search is literal or pattern-based. The pod lead records the unresolved check and next receiving owner. Group agreement does not replace each person's observation.
Candidate / command / case / output location:
My prediction / actual error or workspace-ID pairs:
Statement text / bound values / scope source:
Intended exact, literal-substring or pattern match:
Allowed control / forbidden-row or changed-input control:
What this local result establishes / remaining environment check:
Receiving owner / next evidence / next update:
My contribution / help received / changed-copy explanation:If the receiver cannot locate the missing condition or explain the percent case, repeat that comparison and retain the first attempt. These observations demonstrate bounded query interpretation, not independent client access or production isolation. The Python value-binding guidance and SQLite LIKE and ESCAPE semantics, checked 27 October 2026, ground the mechanism. The fictional fixture and receiving exercise are original LockedIn Labs material.