oracle - I want to have only 3 columns (departure_City_Id, arrival_City_Id, Emp_number). However, when I come to insert value , it says that I have 4 columns -
for epms table, want have 3 columns (departure_city_id, arrival_city_id, emp_number). however, when come insert value, says have 4 columns. 1 city_id. want avoid having city_id column in table. declare because need fk.
create table city ( city_id char(3), state varchar(30), primary key (city_id) ); create table emps ( emp_number varchar(30) primary key, city_id char(3), departure_city_id char(3), arrival_city_id char(3), foreign key (city_id) references city(city_id), foreign key (city_id) references city(city_id) );
this pretty straightforward, specify e.g. , foreign key (arrival_city_id) references city(city_id)
, you'll index.
create table emps ( emp_number varchar(30) not null, city_id char(3) not null, departure_city_id char(3) not null, arrival_city_id char(3) not null, primary key (emp_number), key city_id (city_id), key departure_city_id (departure_city_id), key arrival_city_id (arrival_city_id), constraint emps_ibfk_1 foreign key (city_id) references city (city_id), constraint emps_ibfk_2 foreign key (departure_city_id) references city (city_id), constraint emps_ibfk_3 foreign key (arrival_city_id) references city (city_id) ) engine=innodb default charset=utf8mb4;
Comments
Post a Comment