1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| create table dbo.station
(
idstation int identity(1, 1) not null
, station char(1) not null
, nbr int not null
, constraint pk_station primary key (idstation)
, constraint ak_station unique (station)
);
create table dbo.distance
(
iddistance int identity(1, 1) not null
, ArretInitial char(1) not null
, ArretFinal char(1) not null
, distance decimal(5,2) not null default 0
, constraint pk_distance primary key (iddistance)
, constraint fk_distance_station_initial
foreign key (ArretInitial)
references dbo.station (station)
, constraint fk_distance_station_final
foreign key (ArretFinal)
references dbo.station (station)
);
insert into station (station, nbr) values ('F', 12);
insert into station (station, nbr) values ('R', 15);
insert into station (station, nbr) values ('J', 2);
insert into station (station, nbr) values ('S', 8);
insert into station (station, nbr) values ('H', 5); |
Partager