Sadman Rizwan
Sadman Rizwan

Reputation: 309

Multiple foreign key referencing same attribute

If a table has multiple foreign keys which reference same attribute of another table, how should be it written?

foreign key(A,B) references table_name(C)

or,

foreign key(A,B) references table_name(C,C)

here, A,B,C are attributes.

Upvotes: 0

Views: 1913

Answers (2)

Abdullah Dibas
Abdullah Dibas

Reputation: 1507

No you should create two foreign keys referencing the same primary key. As follows:

foreign key(A) references table_name(C)

foreign key(B) references table_name(C)

Upvotes: 0

Gordon Linoff
Gordon Linoff

Reputation: 1269813

It is written as two foreign key references:

foreign key (A) references table_name(C),
foreign key (B) references table_name(C),

That is, each foreign key reference is defined using its own clause.

Upvotes: 1

Related Questions