Dbase 1
Dbase 1
rules.
To enforce the property that duplicate rows are forbidden, each relation must have its own primary
key. A primary key is one or more columns of a table where values are used to uniquely identify each
of the rows in a table.
In the above example, the DeptNo field in the Department table is a foreign key. It is linked to the
DeptNo field in the Employee table which is a primary key. For any given record, the value of
Department.DeptNo will match the value of Employee.DeptNo.
A foreign key is a field that is linked to another table‘s primary key field in a relationship between
two tables.
Employee table
Departments
EmpNo DeptNo
DeptNo Dname
Location
In relational database management systems, a relationship defines a relationship between two
or more tables. That is, the data in one table is related to the data in the other. One table
contains the primary key and the other table contains the foreign key.
When we establish a relationship between the tables, we link the foreign key with the primary
key. From that point on, any value in the foreign key field should match a value from the
primary key field in the other table.
So foreign keys are an essential part of relational database systems. Without foreign keys, we
wouldn’t be able to match data in one table with data from another. At least, we wouldn’t be
able to match it with full confidence that the results are correct. This is because the value of the
primary field is a unique identifier.
Therefore, the value of the foreign key field is the unique identifier for the record in the other
table. So we know that the foreign key value refers to only that single record.