# Foreign key claim check

`foreign-key-claim-check` · version 1.0.0 · Numbers & math · free, no key needed

Check an exact referential-inclusion claim and first violation under an explicit composite-null policy.

**Use when you need to: check claimed foreign key · validate referential inclusion certificate · verify first foreign key violation.**

## Decide before calling

Read the [versioned contract](/v1/tools/foreign-key-claim-check/versions/1.0.0) and the supported scope below. Reuse `foreign-key-claim-check@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `foreign-key-claim-check@1.0.0` for check claimed foreign key. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- check claimed foreign key
- validate referential inclusion certificate
- verify first foreign key violation
- audit referential constraint result
- check composite foreign key nulls
- test parent child inclusion claim

## Not supported

- modify or repair source rows
- infer columns or null policy
- execute SQL or access a database

## Behavior

- Rows are scanned in ascending source index; columns retain caller order.
- Cell equality is type-strict over null, booleans, safe integers other than -0, and Unicode strings by code point sequence.
- A well-typed false claim returns valid false and the first field discrepancy; malformed input throws.
- reference_version identifies ISO/IEC 9075-2:2023 §4.18, §11.8, and §11.9 narrowed by the packet README.

## Input

- `child_rows` (array of object, required): max items 1000
- `parent_rows` (array of object, required): max items 1000
- `child_columns` (array of string, required): min items 1; max items 16; each min length 1; each max length 1024
- `parent_columns` (array of string, required): min items 1; max items 16; each min length 1; each max length 1024
- `null_policy` (one of "match_simple", "nulls_equal", "reject", required)
- `claim` (object, required)

## Output

- `valid` (boolean, required)
- `reason` (string, required)
- `discrepancy` (null or object, required)
- `reference_version` (constant "ISO/IEC 9075-2:2023 §4.18, §11.8, §11.9 (narrowed profile)", required)

## Limits

- max input bytes: 262144
- max rows: 1000
- max columns: 16
- max cell string bytes: 1024

## Example

Request input:

```json
{
  "child_rows": [
    {
      "pid": 1
    }
  ],
  "parent_rows": [
    {
      "id": 1
    }
  ],
  "child_columns": [
    "pid"
  ],
  "parent_columns": [
    "id"
  ],
  "null_policy": "match_simple",
  "claim": {
    "satisfied": true,
    "first_violation_index": null
  }
}
```

Response:

```json
{
  "result": {
    "valid": true,
    "reason": "claim_exact",
    "discrepancy": null,
    "reference_version": "ISO/IEC 9075-2:2023 §4.18, §11.8, §11.9 (narrowed profile)"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "foreign-key-claim-check",
  "version": "1.0.0",
  "input": {
    "child_rows": [
      {
        "pid": 1
      }
    ],
    "parent_rows": [
      {
        "id": 1
      }
    ],
    "child_columns": [
      "pid"
    ],
    "parent_columns": [
      "id"
    ],
    "null_policy": "match_simple",
    "claim": {
      "satisfied": true,
      "first_violation_index": null
    }
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/foreign-key-claim-check/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"child_rows":[{"pid":1}],"parent_rows":[{"id":1}],"child_columns":["pid"],"parent_columns":["id"],"null_policy":"match_simple","claim":{"satisfied":true,"first_violation_index":null}}'
```

The machine-readable contract is at [/v1/tools/foreign-key-claim-check/versions/1.0.0](/v1/tools/foreign-key-claim-check/versions/1.0.0).

### CLI

```sh
node cli.mjs run foreign-key-claim-check 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Unique key claim check](/tools/unique-key-claim-check): Check an exact uniqueness claim and first-duplicate certificate under an explicit SQL null policy.
- [Candidate key claim check](/tools/candidate-key-claim-check): Check an exact candidate-key claim, including uniqueness and minimality, under an explicit SQL null policy.
- [Join inner result check](/tools/join-inner-result-check): Check a claimed ordered inner join index result and report its first discrepancy.
- [Join left result check](/tools/join-left-result-check): Check a claimed ordered left join index result and report its first discrepancy.
- [Join semi result check](/tools/join-semi-result-check): Check a claimed ordered semi-join index result and report its first discrepancy.
- [Dedupe first check](/tools/dedupe-first-check): Check an exact first-wins SameValueZero deduplication claim and report its first discrepancy.
