drop table if exists specialties cascade;
create table specialties(
	specialty_id serial,
	specialty_name varchar(64),
	oldid integer,
	constraint specialties_specialty_id_pkey primary key(specialty_id)
);

comment on table specialties is 'storage of specialties';
comment on column specialties.specialty_id is 'unique id of table';
comment on column specialties.specialty_name is 'name of the specialty';
comment on column specialties.oldid is 'migrational column';

comment on constraint specialties_specialty_id_pkey on specialties is 'unique constraint of table';

drop table if exists specialty_langdefs cascade;
create table specialty_langdefs(
	site_language_id integer not null references site_languages( site_language_id ),
	specialty_id integer not null references specialties( specialty_id ),
	langdef_name varchar(64),
	langdef_aliasname varchar(64),
	langdef_ordering integer,
	constraint specialty_langdefs_xref_pkey primary key(site_language_id,specialty_id)
);

comment on table specialty_langdefs is 'table of specialty language definitions';
comment on column specialty_langdefs.site_language_id is 'reference id to site_languages table';
comment on column specialty_langdefs.specialty_id is 'reference id to specialties table';
comment on column specialty_langdefs.langdef_name is 'name of the language definition';
comment on column specialty_langdefs.langdef_aliasname is 'aliasname of the language definition';
comment on column specialty_langdefs.langdef_ordering is 'ordering of the language definition';


comment on constraint specialty_langdefs_xref_pkey on specialty_langdefs is 'unique constraint of table (on site_specialty_id + specialty_id )';
comment on constraint specialty_langdefs_site_language_id_fkey on specialty_langdefs is 'foreign constraint to site_languages table';
comment on constraint specialty_langdefs_specialty_id_fkey on specialty_langdefs is 'foreign constraint to specialties table';

