connect to ics321;

-- we use the sequence ID (seqid) to simulate the sorted order of the records
-- in a heap file. By looking at the how jumbled up the sequence ids are for
-- the sorted order of an index we can get an intuition of how clustered the
-- index will be 

drop table reserves;
create table reserves(seqid int generated by default as identity, sid int, bid int, day int);

insert into reserves(sid,bid,day) values(1,1,1);
insert into reserves(sid,bid,day) values(1,1,2);
insert into reserves(sid,bid,day) values(1,1,3);
insert into reserves(sid,bid,day) values(1,2,1);
insert into reserves(sid,bid,day) values(1,2,2);
insert into reserves(sid,bid,day) values(1,2,3);
insert into reserves(sid,bid,day) values(1,3,1);
insert into reserves(sid,bid,day) values(1,3,2);
insert into reserves(sid,bid,day) values(1,3,3);
insert into reserves(sid,bid,day) values(2,1,1);
insert into reserves(sid,bid,day) values(2,1,2);
insert into reserves(sid,bid,day) values(2,1,3);
insert into reserves(sid,bid,day) values(2,2,1);
insert into reserves(sid,bid,day) values(2,2,2);
insert into reserves(sid,bid,day) values(2,2,3);
insert into reserves(sid,bid,day) values(2,3,1);
insert into reserves(sid,bid,day) values(2,3,2);
insert into reserves(sid,bid,day) values(2,3,3);

-- simulate the order of leaf pages of an index on sid, bid, day
select * from reserves order by sid, bid, day;

-- simulate the order of leaf pages of an index on bid, day
select * from reserves order by bid, day;

-- simulate the order of leaf pages of an index on sid, bid
select * from reserves order by sid, bid;

-- simulate the order of leaf pages of an index on sid
select * from reserves order by sid;

-- simulate the order of leaf pages of an index on bid
select * from reserves order by bid;

connect reset;
