drop table if exists job_servicetypes;
create table job_servicetypes(
	job_servicetype_id serial,
	job_id integer not null references jobs( job_id ),
	servicetype_id integer not null references servicetypes( servicetype_id ),
	servicetype_unit_id integer not null references servicetype_units( servicetype_unit_id ),
	quantity integer not null,
	constraint job_servicetypes_job_servicetype_id_pkey primary key( job_servicetype_id )
);

comment on table job_servicetypes is 'storage of job servicetypes';
comment on column job_servicetypes.job_servicetype_id is 'unique id of table';
comment on column job_servicetypes.job_id is 'reference id to jobs table';
comment on column job_servicetypes.servicetype_id is 'reference id to servicetypes table';
comment on column job_servicetypes.servicetype_unit_id is 'reference id to servicetype_units table';
comment on column job_servicetypes.quantity is 'quantity of service';

comment on constraint job_servicetypes_job_servicetype_id_pkey on job_servicetypes is 'unique constraint of table';
comment on constraint job_servicetypes_job_id_fkey on job_servicetypes is 'foreign constraint to jobs table';
comment on constraint job_servicetypes_servicetype_id_fkey on job_servicetypes is 'foreign constraint to servicetypes table';
comment on constraint job_servicetypes_servicetype_unit_id_fkey on job_servicetypes is 'foreign constraint to servicetype_units table';

create index job_servicetypes_job_id_ind on job_servicetypes( job_id );
comment on index job_servicetypes_job_id_ind is 'index on job_id';
