views:

53

answers:

0

Hi,

I have the following tables:

  • Data
    • ID
    • ...
  • Relationships
    • ParentID //points to Data:ID
    • ChildID //points to Data:ID too

If I bring both the DATA and RELATIONSHIPS table into a dataset, is there a way to add the relationships into the model in a way that would add value? e.g. to enforce the constraints for example? If so I guess I'm interested in:

Q1 - Is it possible?

Q2 - What would the code look like to set up the relationships?

Q3 - How could this be leverage for say the Add_Child_to_Parent use case, where you want to the following (or in other words how much of the ADO.net relationship setup would do such checking/validation for me):

  • check if the parent exists first
  • if not then create parent
  • check child exists then error out (as would be duplicate)
  • create child
  • create the RELATIONSHIP entry that tie the two together

Thanks