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 sequence resource_session_archive_seq;
create sequence resource_session_archive_seq;

drop table daily_summary;
create table daily_summary (
    ds_id           int,
    ds_desc         varchar(30)
);

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)
);

drop table resource_session_archive;
create table resource_session_archive (
    rsa_id         int,
    rsa_res_id      int,
    rsa_start_time  int,
    rsa_end_time    int,
    rsa_cost        real,
    rsa_notes       varchar(30)
);

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 resource values ( nextval('resource_seq'), 1, 'Table 1', 2, 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', 2, 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', 2, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 16, 'Table 16', 2, 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', 3, 0, 0, NULL);
insert into resource values ( nextval('resource_seq'), 19, 'Darts', 5, 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, 'Private Table' );
insert into rate_scheme values ( 4, 'Pool Table' );
insert into rate_scheme values ( 5, 'Darts' );

insert into rate_scheme_entry values ( 1, nextval('rate_scheme_entry_seq'), 0,         2.30 );
insert into rate_scheme_entry values ( 2, nextval('rate_scheme_entry_seq'), 0,         2.70 );
insert into rate_scheme_entry values ( 3, nextval('rate_scheme_entry_seq'), 0,         3.20 );
insert into rate_scheme_entry values ( 4, nextval('rate_scheme_entry_seq'), 0,         2.30 );
insert into rate_scheme_entry values ( 5, nextval('rate_scheme_entry_seq'), 0,         0.60 );
