Skip to content

Instantly share code, notes, and snippets.

@edgarogh
Created March 16, 2022 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edgarogh/27ea7fcb970f4cc9a297ebba7fd5d3a7 to your computer and use it in GitHub Desktop.
Save edgarogh/27ea7fcb970f4cc9a297ebba7fd5d3a7 to your computer and use it in GitHub Desktop.
Simple tags system with a notion of parents. May be used for file paths, I guess.
Licensed as CC-0
create table tags (
id text not null check (id <> ''),
parent text generated always as ((regexp_match(id, '^(.*)/[0-9a-z_]+$'))[1]) stored,
foreign key (parent) references tags,
primary key (id)
);
insert into tags values ('game');
insert into tags values ('game/rpg');
insert into tags values ('game/action');
insert into tags values ('game/arcade');
insert into tags values ('game/arcade/2d');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment