what is for foreign key ??

Answer Posted / akhtar mohammad kalim

A foreign key is a field (or fields) that points to the
primary key of another table. The purpose of the foreign
key is to ensure referential integrity of the data. In
other words, only values that are supposed to appear in the
database are permitted.

For example, say we have two tables, a CUSTOMER table that
includes all customer data, and an ORDERS table that
includes all customer orders. The constraint here is that
all orders must be associated with a customer that is
already in the CUSTOMER table. In this case, we will place
a foreign key on the ORDERS table and have it relate to the
primary key of the CUSTOMER table. This way, we can ensure
that all orders in the ORDERS table are related to a
customer in the CUSTOMER table. In other words, the ORDERS
table cannot contain information on a customer that is not
in the CUSTOMER table.

The structure of these two tables will be as follows:

Table CUSTOMER column name characteristic
SID Primary Key
Last_Name
First_Name


Table ORDERS column name characteristic
Order_ID Primary Key
Order_Date
Customer_SID Foreign Key
Amount


In the above example, the Customer_SID column in the ORDERS
table is a foreign key pointing to the SID column in the
CUSTOMER table.

Is This Answer Correct ?    9 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

on line cluster can we make if yes tell me the procedure

1517


Give main differences between "Truncate" and "Delete".

585


List out what other servers you can use with ssrs?

93


How to deploy the Report?

95


Can you please differentiate between a primary key and a unique key?

537






What are the new features introduced in SQL Server 2000? What changed between the previous version of SQL Server and the current version?

1854


what are triggers? : Sql server database administration

509


What are the basic features of a trigger in ms sql server?

570


What are the basic functions for master, msdb, model, tempdb and resource databases?

557


What is a constant or literal in ms sql server?

603


What is read uncmmited?

585


Explain the relational database management system (rdbms)?

532


What is data mart? : sql server analysis services, ssas

600


you added a row to a view, but the row is not shown on the view. Explain how this can happen, and how you can remedy the situation

542


What is use of @@ spid in sql server?

687