nooki
08/03/2021, 6:10 AM0xhjohnson
08/03/2021, 1:52 PM0xhjohnson
08/03/2021, 1:55 PM— table for the options
create table select_options (
id uuid primary key default uuid_generate_v4(),
name text not null
);
— some other table
create table other_table (
select_option_id uuid references select_options not null
);
tocteman
08/03/2021, 3:22 PMcreate table options (
option_type varchar primary key
);
create table items (
id bigint primary key,
option_type references options
);
insert into options (option_type) values ('allowed'), ('allowed_as_well');
it's quite convenient, as you get to control what values are accepted, you keep your relational guarantees, it stays readable and you get to save quite a bit of joins