Skip to content

Data subject within non-data subject table (sample application: Mouthful) #171

@benkilimnik

Description

@benkilimnik

Encountered in the sample application schema for Mouthful located in experiments/schema-annot/annotated/mouthful-annotated.sql

K9db cannot accurately capture the Author column in the Comment table which refers to a data subject that owns all data. (The entire application contains just two tables: Comment and Thread).

CREATE TABLE Thread(
    Id int PRIMARY KEY,
    CreatedAt datetime not null,
    Path text not null
);

CREATE TABLE Comment(
    Id int PRIMARY KEY,
    ThreadId int not null,
    Body text not null,
    Author text not null,
    Confirmed int not null,
    CreatedAt datetime not null,
    ReplyTo int not null,
    DeletedAt datetime not null,
    FOREIGN KEY(ThreadId) references Thread(Id),
);

Work around: modify schema by adding a separate user table

CREATE DATA_SUBJECT TABLE user (
    id text PRIMARY KEY
);

and then adding a foreign key to user(id) in Comment

FOREIGN KEY(Author) OWNED_BY user(id)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions