create schema camp;

create type camp.enum_camp as enum ('Gemeindefreizeit 2025');
create type camp.enum_sex as enum ('männlich', 'weiblich');

create table camp.t_registration(
	created timestamp without time zone default current_timestamp,
	pk_registration int not null primary key generated always as identity,
	registrator text not null,
	camp camp.enum_camp not null,
	forename text not null,
	surname text not null,
	sex camp.enum_sex not null,
	unique(camp, forename, surname)
);

create view camp.v_participant as
select sum(case when sex = 'männlich' then 1 else 0 end) as males,
       sum(case when sex = 'weiblich' then 1 else 0 end) as females
from camp.t_registration;

create or replace view v_version as
select 5 as version;
