create schema authorization barbier
create table Terminal(terminal varchar(30),clockwise_next varchar(30),counterclockwise_next varchar(30),
constraint Terminal_key primary key(terminal))
create table Railcar(railcar varchar(30),origin varchar(30),end varchar(30),is_clockwise number(1),
constraint Railcar_key primary key(railcar),
constraint Railcar_foreign_key foreign key(origin) references Terminal(terminal),
constraint Railcar_foreign_key2 foreign key(end) references Terminal(terminal));

insert into Terminal values('T1','T2','T4');
insert into Terminal values('T2','T3','T1');
insert into Terminal values('T3','T4','T2');
insert into Terminal values('T4','T1','T3');

insert into Railcar values('R1','T1','T2',1);
insert into Railcar values('R2','T1','T2',1);
insert into Railcar values('R3','T2','T3',0);

commit;