Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brainstorming: Is a good UI for editing join tables possible? #55

Open
cldellow opened this issue Feb 6, 2023 · 1 comment
Open

brainstorming: Is a good UI for editing join tables possible? #55

cldellow opened this issue Feb 6, 2023 · 1 comment

Comments

@cldellow
Copy link
Owner

cldellow commented Feb 6, 2023

Imagine:

CREATE TABLE post(
  id integer primary key,
  title text
);

CREATE TABLE tag(
  id integer primary key,
  title text
);

CREATE TABLE post_tag(
  post_id integer references post(id),
  tag_id integer references tag(id),
  primary key(post_id, tag_id)
);

Or:

CREATE TABLE post(
  id integer primary key,
  title text
);

CREATE TABLE post_tag(
  post_id integer not null references post(id),
  tag text not null,
  primary key(post_id, tag)
);

Is there a way this can fit into the editing model such that the user sees a list of tags when looking at /db/post/1 ?

The currently proposal would have the user go to /db/post to create the post, go to /db/tag to create the tags, then go to /db/post_tag and create new records. It works, but is very clunky.

@cldellow cldellow changed the title Is a good UI for join tables possible? brainstorming: Is a good UI for join tables possible? Feb 6, 2023
@cldellow cldellow changed the title brainstorming: Is a good UI for join tables possible? brainstorming: Is a good UI for editing join tables possible? Feb 6, 2023
@cldellow
Copy link
Owner Author

cldellow commented Feb 6, 2023

Proposal: special-case this scenario for base tables (but not views).

Render a UI that lets you add/delete tags. It will feel a little jarring, as it will get tacked on outside of the main table with the other controls. That's probably worth it.

Why not views: because the principle of views is that you explicitly opt some columns in. But currently, views have to draw from a single table to be editable.

Maybe long term we can expand VIEW support to recognize and permit things of the shape:

SELECT id, title agg(tag)
FROM post
LEFT JOIN post_tag ON post.id = post_tag.post_id
GROUP BY 1, 2

Then we'd:

  • render an appropriate multi select UI
  • create appropriate INSTEAD OF triggers

Tedious, but not technically complicated. But also, no back compat challenges, so doesn't have to be part of v1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant