Problem solve Get help with specific problems with your technologies, process and projects.

What is a foreign key?

What is a foreign key, and what are the actual rules for a foreign key?

This is one of the key concepts in relational databases. Foreign keys are what allow the database designer to express the relationships between rows.

Every table in a database should have a declared "primary key". The primary key is a column or group of columns that will uniquely identify a row within a table. One of the easiest (and most efficient) ways to do this is to create an automatically incrementing numeric column that serves no purpose other than to identify the row.

A "foreign key" is a copy of a primary key of a "parent' row that is stored within the "child" row. For example, consider a time and billing system. Each row of WIP (Work In Progress) can belong on a bill, so the wip row should include a BillId column that can be NULL. When the row is inserted into the table, the BillId is NULL. Once the wip has been billed, the BillId of the related bill is put into the wip's BillId column, showing that this row of wip "belongs" to that bill.

For More Information

Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.