Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is a foreign key ?

foreign key
0
Posted

What is a foreign key ?

0

FOREIGN KEY Constraint : 1. Enforces referential integrity constraint which requires that for each row of a tbale , the value in the foreign key matches a value in the primary key or is null. 2. No limit to the number of foreign keys. 3. can be in the same table as referenced primary key. 4. can not reference a remote table or synonym. Examples : 1. Explicit reference to a PRIMARY KEY column CREATE TABLE accounts( account NUMBER(10) , CONSTRAINT borrower FOREIGN KEY (account) REFERENCES customer(account), ………); 2. Implicit reference to a PRIMARY KEY column CREATE TABLE accounts( account NUMBER(10), CONSTRAINT borrower FOREIGN KEY (account) REFERENCES customer, …….

0

A foreign key is the primary key of one entity that is copied into another entity. The objective of a foreign key is to provide a relationship between the two entities. The example given below describes a foreign key. For example, there are two tables, Author and Book. Author AuthorID Name Contact No. Address Book BookID Title Category AuthorID Here, AuthorID is the primary key of the Author table, and it is migrated from the Author table to the Book table. In the Book table, it is referred to as the foreign key. Note: Here, in the above example, AuthorID becomes the foreign key in the Book table.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123