drop sequence resource_seq;
create sequence resource_seq start 0 minvalue 0;

drop sequence rate_scheme_entry_seq;
create sequence rate_scheme_entry_seq;

drop table resource;
create table resource (
    res_id          int,
    res_portno      int,
    res_name        varchar(30),
    res_rate_scheme int,
    res_status      int,
    res_start_time  int,
    res_notes       varchar(30)
);
create unique index resource_i1 on resource(res_id);

drop table resource_session;
create table resource_session (
    rs_res_id      int,
    rs_start_time  int,
    rs_end_time    int,
    rs_cost        real,
    rs_notes       varchar(30)
);
create unique index resource_session_i1 on resource_session(rs_res_id);

drop table rate_scheme;
create table rate_scheme (
   rsc_id          int,
   rsc_desc        varchar(30)
);
create unique index rate_scheme_i1 on rate_scheme(rsc_id);

drop table rate_scheme_entry;
create table rate_scheme_entry (
   rse_rsc_id      int,
   rse_id          int,
   rse_start       int,
   rse_rate        real
);
create unique index rate_scheme_entry_i1 on rate_scheme_entry(rse_id, rse_start);

insert into seqnos values ( 'RateSchemeEntry', 0 );

insert into resource values ( nextval('resource_seq'), 1, 'Table 1', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 2, 'Table 2', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 3, 'Table 3', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 4, 'Table 4', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 5, 'Table 5', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 6, 'Table 6', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 7, 'Table 7', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 8, 'Table 8', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 9, 'Table 9', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 10, 'Table 10', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 11, 'Table 11', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 12, 'Table 12', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 13, 'Table 13', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 14, 'Table 14', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 15, 'Table 15', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 16, 'Table 16', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 17, 'Table 17', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 18, 'Table 18', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 19, 'Table 19', 1, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 20, 'Pool', 3, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 21, 'Darts', 4, 0, 0, NULL);

insert into rate_scheme values ( 1, 'Standard Snooker Table' );
insert into rate_scheme values ( 2, 'Matchplay Snooker Table' );
insert into rate_scheme values ( 3, 'Pool Table' );
insert into rate_scheme values ( 4, 'Darts' );

insert into rate_scheme_entry values ( 1, nextval('rate_scheme_entry_seq'), 0,         1.01 );
insert into rate_scheme_entry values ( 2, nextval('rate_scheme_entry_seq'), 0,         2.01 );
insert into rate_scheme_entry values ( 2, nextval('rate_scheme_entry_seq'), 86400,     2.02 );
insert into rate_scheme_entry values ( 2, nextval('rate_scheme_entry_seq'), 172800,    2.03 );
insert into rate_scheme_entry values ( 2, nextval('rate_scheme_entry_seq'), 259200,    2.04 );
insert into rate_scheme_entry values ( 2, nextval('rate_scheme_entry_seq'), 345600,    2.05 );
insert into rate_scheme_entry values ( 2, nextval('rate_scheme_entry_seq'), 432000,    2.06 );
insert into rate_scheme_entry values ( 2, nextval('rate_scheme_entry_seq'), 518400,    2.07 );
insert into rate_scheme_entry values ( 3, nextval('rate_scheme_entry_seq'), 0,         3.01 );
insert into rate_scheme_entry values ( 3, nextval('rate_scheme_entry_seq'), 86400,     3.02 );
insert into rate_scheme_entry values ( 3, nextval('rate_scheme_entry_seq'), 172800,    3.03 );
insert into rate_scheme_entry values ( 3, nextval('rate_scheme_entry_seq'), 259200,    3.04 );
insert into rate_scheme_entry values ( 3, nextval('rate_scheme_entry_seq'), 345600,    3.05 );
insert into rate_scheme_entry values ( 3, nextval('rate_scheme_entry_seq'), 432000,    3.06 );
insert into rate_scheme_entry values ( 3, nextval('rate_scheme_entry_seq'), 518400,    3.07 );
insert into rate_scheme_entry values ( 4, nextval('rate_scheme_entry_seq'), 0,         4.01 );
insert into rate_scheme_entry values ( 4, nextval('rate_scheme_entry_seq'), 86400,     4.02 );
insert into rate_scheme_entry values ( 4, nextval('rate_scheme_entry_seq'), 172800,    4.03 );
insert into rate_scheme_entry values ( 4, nextval('rate_scheme_entry_seq'), 259200,    4.04 );
insert into rate_scheme_entry values ( 4, nextval('rate_scheme_entry_seq'), 345600,    4.05 );
insert into rate_scheme_entry values ( 4, nextval('rate_scheme_entry_seq'), 432000,    4.06 );
insert into rate_scheme_entry values ( 4, nextval('rate_scheme_entry_seq'), 518400,    4.07 );
