jackc / jackc/doublecheck

Declaratively generate diamond FK constraint views and triggers

Open
#1 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
11
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Given tables A, B, C, and D where B and C belong to A and D belongs to C and D we want to guarantee that B and C belong to the same A.

```
A
/ \
B C
\ /
D
```

The SQL view to detect errors is something like:

```sql
create view d_consistency as
select d.id, d.b_id, d.c_id
from d
join b on d.b_id=b.id
join c on d.c_id=c.id
where b.a_id<>c.a_id;
```

Then we would need triggers on b, c, and d to check if the proposed change shows up in this view.

Contributor guide

No contributing guide indexed for this repository

Research direction

No files, tests, or entry points are named in the issue. First establish the project's intended declarative API for defining the A–B–C–D relationship; done means generating the consistency view and triggers for the diamond and checking proposed changes on B, C, and D.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.