What is the difference between foreign key and primary key concept

Asked By 7060 points N/A Posted on -
qa-featured

What is the difference between foreign key and primary key concept and what is a purpose of foreign Key and primary key in Relational Database Management System, What is the role of each key during designing a database, is it necessary using both keys ?

SHARE
Best Answer by RobsampsonC
Best Answer
Best Answer
Answered By 0 points N/A #81305

What is the difference between foreign key and primary key concept

qa-featured

Primary key is a combination of columns that defines a row in a table of a rational database uniquely.

A table can have maximum 1 primary key and it enforces the implicit not null constraint which means that primary key cannot have null value in it.

Foreign key identifies a set of columns or a column in a table, It is called referencing table and that refers a set of columns in other table is called referenced table.

Foreign key is required or used to link data across several tables.

In a database, Table can have multiple foreign keys but only 1 primary key.

table can have a single primary key, but it can have multiple foreign keys that can reference different tables

Answered By 0 points N/A #81307

What is the difference between foreign key and primary key concept

qa-featured

 

Basically Primary key is key which uniquely describes row in a table of the database and doesn’t not allow data redundancy. On the other hand foreign key is the key which refers to the primary key of the other table and hence are used to link the tables.

But coming towards you point the difference between foreign key and primary key is :>>

Primary key is column or set of column which can be used to identify row in table, while foreign key is key referring other  table’s primary key . Primary key cannot be used to link several tables unlike foreign key. Also tables can have multiple foreign key but they can only have a single primary key.

Answered By 10 points N/A #81308

What is the difference between foreign key and primary key concept

qa-featured

A primary key is what is used as the primary referral point in a table and it is used to uniquely identify each row in a table. In most tables the primary key value are always chosen from number attributes. For instance, primary keys are chosen from attributes like customers PIN number, student number, registration number and so forth.

A foreign key, just like the primary key, uniquely identifies rows in the table that it is declared it, but so that all the tables are linked together to form a relationship, the foreign key is referenced to the primary key.

Hope this helps.

___

Regards,

Lee Hung.

Login/Register to Answer

Related Questions