Reputation: 1
Is it possible to make a column not primary key, to be foreign key in other table? for example :
-- for master table
create table identity(
id int not null,
name_identity varchar2(100),
primary key(id)
);
--for foreign key
create table class(
class_id int,
name_identity varchar2(100),
primary key(class_id),
foreign key(name_identity) references identity(name_identity)
);
Is it possible to make name_identity as foreign key?
Upvotes: 0
Views: 58
Reputation: 2496
Foreign key doesn't rely on column, it's rely on unique key instead. Primary key is a special case of unique key so it can be used as well.
In your case you should use something like name_identity varchar2(100) unique
and you'll can use it in foreign key after that.
Upvotes: 1