drop table if exists member_memberships cascade;
create table member_memberships(
	member_id integer not null references members( member_id ),
	membership_id integer not null references memberships( membership_id ),
	constraint member_membership_xref_pkey primary key( member_id , membership_id )
);

comment on table member_memberships is 'storage of member memberships';
comment on column member_memberships.member_id is 'reference id to members table';
comment on column member_memberships.membership_id is 'reference id to memberships table';

comment on constraint member_membership_xref_pkey on member_memberships is 'unique complex constraint of table';
comment on constraint member_memberships_member_id_fkey on member_memberships is 'foreign constraint to members table';
comment on constraint member_memberships_membership_id_fkey on member_memberships is 'foreign constraint to memberships table';

create index member_memberships_member_id_ind on member_memberships( member_id );
comment on index member_memberships_member_id_ind is 'member_id index';
create index member_memberships_membership_id_ind on member_memberships( membership_id );
comment on index member_memberships_membership_id_ind is 'membership_id index';
