create table user
  ( id integer primary key
  , name text unique not null
  , is_admin bool
  );

create table link
  ( id integer primary key
  , url text not null
  , name text not null
  , description text not null
  , created datetime not null
  , private bool not null
  , user integer not null
  , foreign key(user) references user(id)
  );

create table tag
  ( id integer primary key
  , name text not null
  , parent integer not null
  , user integer not null
  , foreign key(parent) references tag(id)
  , foreign key(user) references user(id)
  , unique(name, user)
  );

create table has_tag
  ( id integer primary key
  , link integer not null
  , user integer not null
  , foreign key(link) references link(id)
  , foreign key(user) references user(id)
  , unique(link, user)
  );

create table user_invite
  ( id integer primary key
  , token text not null
  );
