У меня есть следующий код в MySQL.
create table employee(
e_id int(10) not null auto_increment,
user_id int(10),
usertype_id default 1,
name varchar(50),
primary key (e_id)
);
create table relation(
r_id int(10) not null auto_increment,
user_id int(10) not null,
usertype_id int(10) not null,
interest_id int(10) not null,
primary key (id)
);
Во-первых, я хочу, чтобы user_id
имел то же значение, что и столбец e_id
;
И затем я хочу добавить user_id
и usertype_id
в качестве единства в таблице relation
в качестве внешнего ключа для user_id
и usertype_id
в таблице employee
.
Ты знаешь, как это сделать?
Большое спасибо.