what is difference between foreign key and reference key

Answer Posted / suresh kumar

Hi, i give the definitions with easy understand exapmles

A primary key is used to uniquely identify each row in a
table. It can either be part of the actual record itself,
or it can be an artificial field (one that has nothing to
do with the actual record).
A primary key can consist of one or more fields on a table.
When multiple fields are used as a primary key, they are
called a composite key.

EX:If we take EMP table, Empno is the primary key and in
DEPT table, Deptno is the primary keys

A foreign key is a field (or fields) that points to the
primary key of another table.
The purpose of the foreign key is to ensure referential
integrity of the data.
In other words, only values that are supposed to appear in
the database are permitted

EX:In EMP table Deptno field is the foreign key because it
pointing to the Deptno in DEPT table

A Reference key is a field (or fields) that points to the
primary key of the same table

EX:In EMP table Mgr field is the Reference key because it
pointing to the Empno field in the same table

Is This Answer Correct ?    64 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to use group functions in the select clause using oracle?

587


What is a sub query? Describe its types?

536


What are the ways tablespaces can be managed and how do they differ?

1612


How can I create database in oracle?

559


Explain rename?

545






How to calculate date and time differences in oracle?

521


Why do I get unexpected characters from 8-bit character sets in weblogic jdriver for oracle?

604


How to run queries on external tables?

560


Is primary key indexed by default in oracle?

538


Why is oracle so popular?

557


What is recycle bin in Oracle?

709


Which dictionary tables and/or views would you look at to diagnose a locking issue?

1480


Explain the difference between a procedure and a function?

552


What is Trigger in Oracle?

565


What is materialized view in Oracle?

629