\c template1
-- drop database testing;
create database testing with encoding='SQL_ASCII';
\c testing

create table subdivs (
  code char(10) not null,
  name char(35) unique not null,

  primary key (code)
);

create table blah (
  id serial,
  subdiv_code char(10),

  primary key (id),
  foreign key (subdiv_code)
    references subdivs
);

insert into subdivs (code, name)
 values ('VG', 'Village');

begin;
insert into blah (subdiv_code)
 values ('VG');

delete from blah where subdiv_code='VG';

abort;

begin;
insert into blah (subdiv_code)
 values ('VG');

update blah set subdiv_code='VG' where subdiv_code='VG';

delete from blah where subdiv_code='VG';

abort;
