locked
DataRelation and  ForeignKeyConstraint  RRS feed

  • Question

  • User1904516115 posted

    What is the difference between DataRelation and  ForeignKeyConstraint  in ADO.NET?

    Friday, January 11, 2019 6:03 AM

All replies

  • User839733648 posted

    Hi vinodkpasi,

    DataRelation

    A DataRelation is used to relate two DataTable objects to each other through DataColumn objects.

    For example, in a Customer/Orders relationship, the Customers table is the parent and the Orders table is the child of the relationship.

    This is similar to a primary key/foreign key relationship. 

    ForeignKeyConstraint

    Represents an action restriction enforced on a set of columns in a primary key/foreign key relationship when a value or row is either deleted or updated. 

    A DataRelation object can be used to create and enforce a foreign-key constraint, which can be used to maintain referential integrity between a parent and child table in a dataset.

    The DataRelation object is a more general term and can be used for other functions also.

    For more, you could refer to the following links to check the details and related samples.

    https://docs.microsoft.com/en-us/dotnet/api/system.data.datarelation?view=netframework-4.7.2

    https://docs.microsoft.com/en-us/dotnet/api/system.data.foreignkeyconstraint?view=netframework-4.7.2 

    Best Regards,

    Jenifer

    Friday, January 11, 2019 9:52 AM