drop table if exists member_cats cascade;
create table member_cats(
	member_id integer not null references members( member_id ),
	cat_id integer not null references cats( cat_id ),
	level integer default 1,
	constraint member_cat_xref_pkey primary key( member_id , cat_id )
);

comment on table member_cats is 'storage of member cats';
comment on column member_cats.member_id is 'reference id to members table';
comment on column member_cats.cat_id is 'reference id to cats table';
comment on column member_cats.level is 'level of CAT software knowledge';

comment on constraint member_cat_xref_pkey on member_cats is 'unique complex constraint of table';
comment on constraint member_cats_member_id_fkey on member_cats is 'foreign constraint to members table';
comment on constraint member_cats_cat_id_fkey on member_cats is 'foreign constraint to cats table';

create index member_cats_member_id_ind on member_cats( member_id );
comment on index member_cats_member_id_ind is 'member_id index';
create index member_cats_cat_id_ind on member_cats( cat_id );
comment on index member_cats_cat_id_ind is 'cat_id index';
