--
-- TestSelfCreate.txt
--

-- TestSelfCreate.txt is used by TestSelf.java to test the database
--
-- This is part of a three part suite of scripts to test persistence in the same DB
--
-- Comment lines must start with -- and are ignored
-- Lines starting with spaces belongs to last line
-- Checked lines start with comments containing <tag> where <tag> is:
--   c <rows>     ResultSet expects a with <row> columns
--   r <string>   ResultSet expected with <string> result in first row/column
--   u <count>    Update count <count> expected
--   e            Exception must occur

-- TEST 1
-- Correct handling of index creation for foreign keys
-- check the consistency of foreign keys and primary keys
/*e*/create table VEREIN(VCODE CHAR(10) not null);
/*e*/create unique index VEREIN_PK on VEREIN (VCODE);
/*e*/create table BEWERB(VCODE CHAR(10) not null, ID SMALLINT not null);
/*e*/create unique index BEWERB_FK2 on BEWERB(ID);
/*e*/create unique index BEWERB_FK1 on BEWERB(VCODE);
/*e*/alter table BEWERB add constraint bv foreign key (VCODE) references VEREIN (VCODE);

-- null value in not null column
/*e*/insert into verein values (null);
-- referential no matching row
/*e*/insert into bewerb values ('aaaaaaa',18);
-- duplicate row
/*e*/insert into bewerb values ('hijklmn',7);
-- referential integrity row has reference
/*e*/delete from verein where vcode='opqrstu'

/*u0*/SHUTDOWN;

