Computer Science, asked by popstarastha520, 9 months ago

Explain The Term Foreign Key

Answers

Answered by jjka
0

Answer:

The term 'Foreign key' is used in SQL programming. It is generally used to identify a data element from a table in the SQL , the foreign key is generally used to refer the main primary key of the table for more clear understanding look at the following example.

Supplier ( SupplierNumber, Name, Address, Type )

Supplier ( SupplierNumber, Name, Address, Type ) Invoices ( InvoiceNumber, SupplierNumber, Text )

Here SupplierNumber is primary key and Invoice number is the foreign key.

hope you understood.

Answered by smartbrainz
0

In a Database Management System, a Foreign key is a column/columns in a table that references a column of another table.

  • In a Foreign Key relationship, one of the columns is the Primary key of that table. Primary Key is a combination of unique and Not Null values whereas foreign key does allow null values in the respective columns. In case the foreign key column does contain null values, the foreign key constraint is not evaluated at all.  
  • Foreign Key is basically used to implement Referential Integrity between database tables. In a foreign key relationship, the table that holds the Primary Key column is called as the parent and the referencing columns from other tables are called as child tables.
  • A Foreign key relationship can be established with a CREATE TABLE or ALTER TABLE SQL command.
  • Considering a simple example, dept_id is a primary key column in department table whereas dept_id column in employee table has a foreign key relationship with dept_id of department table. While inserting data into the employee table, a user needs to ensure that the dept_id being inserted, should be existing in the department table otherwise the referential integrity between the two table will get violated and result in an error.

To know more about Foreign Key, visit :

https://brainly.in/question/10702307

Similar questions
Physics, 4 months ago