
create sequence seq_alpha minvalue 1 increment 1 start 1 cycle;
create sequence seq_beta minvalue 1 increment 1 start 1 cycle;

create table alpha(
	id		int4
		constraint alpha_id
			not null
			unique
			check( id <> 0 )
			default nextval( 'seq_alpha' ),
	payload		text
		constraint alpha_payload
			not null
			unique
			check( payload <> '' ),
	constraint alpha_pk
		primary key( id )
);

create table beta(
	id		int4
		constraint beta_id
			not null
			unique
			check( id <> 0 )
			default nextval( 'seq_beta' ),
	ref		int4
		constraint beta_ref
			not null
			check( ref <> 0 ),
	info		text
		constraint beta_info
			not null
			unique
			check( info <> '' ),
	constraint beta_pk
		primary key( id ),
	constraint beta_fk
		foreign key( ref )
		references alpha( id )
		match full
		on delete restrict
		on update restrict
		not deferrable
		initially immediate
);

insert into alpha( payload ) values( 'one' );
insert into alpha( payload ) values( 'two' );

insert into beta( ref, info ) values( 1, '1.1' );
