DataSet.Relations and ForeignKeyConstraint

  • Thread starter Thread starter Mus
  • Start date Start date
M

Mus

As far as I understand, setting a relation between two tables in a
dataset means creating a unique (primary key) constraint in one table
and a ForeignKey constrainf in another. If this is correct, than why
do we need both? If am wrong, than what is the difference?
 
Suppose you have Table1 and Table
The following are the columns Col1 through 5 are name of the columns in the respective tables

Table1- Col1,col2,col
Table2- Col1,col4,col

Advantages -
1) When you are entering any value in Table2 for Col1 (i.e. primary key in Table1 and Foreign key in Table2) allows only the values that re present in Table1's Col1. If you try to enter any other values it will give an error.

2) Suppose Table1 is master table and Table2 is transaction table then for every record in master table you can retrive the transactions by grouping the values in the transaction table

Hope u understand my way of explanation
 
Back
Top