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

How many databases Microsoft SQL server provides?

686


What is the maximum size per database for sql server express?

634


What is the difference between join and inner join?

617


What is the difference between set and select?

661


what are the different types of SSRS reports?

116






What are the operating modes in which database mirroring runs?

704


How will you add a dimension to cube? : sql server analysis services, ssas

639


What is a non clustered primary key?

600


What is the difference between count () and rowcount ()?

605


How will you find out if there are expensive SQL statements running or not?

662


How many triggers are possible per table?

720


Please explain the characteristics of a transaction server for example atomicity, consistency, isolation, durability?

575


What is the temp table?

622


You have developed an application which uses many stored procedures and triggers to update various tables users ocassionally get locking problems which tool is best suited to help you diagnose the problem?

657


How to integrate the ssrs reports in application?

631