postgresql 9.4 - Building a primary key with Json columns -


i trying set unique constraint across rows, in of them json data types. since there's no way make json column primary key, thought maybe can hash desired columns , build primary key on hash. example:

create table petshop( name text, fav_food jsonb, md5sum uuid); 

i can following:

select md5(name||fav_food::text) petshop; 

but want performed default and/or trigger insert md5 sum column md5sum. , build pkey on column.

but really, want know if json object unique, , not restrict keys in json. if has better idea, helps!


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -