Types of Keys
Types of Keys
In this key in dbms example, we have two table, teach and department in a school. However,
there is no way to see which search work in which department.
In this table, adding the foreign key in Deptcode to the Teacher name, we can create a
What is the Foreign key?
FOREIGN KEY is a column that creates a relationship between two tables. The purpose of
Foreign keys is to maintain data integrity and allow navigation between two different
instances of an entity. It acts as a cross-reference between two tables as it references the
primary key of another table.
In this key in dbms example, we have two table, teach and department in a school. However,
there is no way to see which search work in which department.
In this table, adding the foreign key in Deptcode to the Teacher name, we can create a
What is the Composite key?
COMPOSITE KEY is a combination of two or more columns that uniquely identify rows
in a table. The combination of columns guarantees uniqueness, though individually
uniqueness is not guaranteed. Hence, they are combined to uniquely identify records
in a table.
It uniquely identifies a record in the relational database It refers to the field in a table which is the primary key of
table. another table.
Only one primary key is allowed in a table. Whereas more than one foreign key is allowed in a table.
It does not allow NULL values . It can also contain NULL values.
Its value cannot be deleted from the parent table. Its value can be deleted from the child table.
It constraint can be implicitly defined on the temporary It constraint cannot be defined on the local or global