Computer Science, asked by Anonymous, 3 months ago

What is a primary key and foreign key ​


Anonymous: thanks!
Anonymous: welcome
aloysiusraj72: Thanks bro
Anonymous: welcome bro
aloysiusraj72: what is your name
Anonymous: chain Singh and ur
Anonymous: what is your name
aloysiusraj72: Ronald
Anonymous: ok

Answers

Answered by Anonymous
1

Explanation:

A foreign key is a column or a set of columns in one table that references the primary key columns in another table. The primary key is defined as a column (or set of columns) where each value is unique and identifies a single row of the table.

Answered by aloysiusraj72
4

Answer:

Difference between Primary Key and Foreign Key

Primary Key:

A primary key is used to ensure data in the specific column is unique. It is a column cannot have NULL values. It is either an existing table column or a column that is specifically generated by the database according to a defined sequence.

Example: Refer the figure –

STUD_NO, as well as STUD_PHONE both, are candidate keys for relation STUDENT but STUD_NO can be chosen as the primary key (only one out of many candidate keys).

Foreign Key:

A foreign key is a column or group of columns in a relational database table that provides a link between data in two tables. It is a column (or columns) that references a column (most often the primary key) of another table.

Example: Refer the figure –

STUD_NO in STUDENT_COURSE is a foreign key to STUD_NO in STUDENT relation.

Similar questions