You must Sign In to post a response.
  • Category: .NET

    SQL Table with Multiple parent and child

    Hello everyone.
    I need a table structure where i can add multiple parent and multiple child.
    Even the child can be a parent to another child.

    Give me the table structure and a small program code if possible.

    Expecting your replies asap. Thank you in advance.
  • #762965
    Hello Arivazhagan Sekar,

    I have never been through this type of situation. So i don't have much knowledge of it. But I understood your question.

    As you told that there could be multiple parent and child even those child can be a multiple parent of another child.

    I suggest you to refer this blog. It might help you to understand the concept that you are looking for.

    Hope this will help you.

    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #762966
    Thank you Nirav. But this it is not enough. Im going thru many code sniffets. Still couldnt find the proper one. Please make some more effort and if possible give me solutions.

    Also im planning to insert the parent and child on run time. so user can add parent and child on their own and even add another child within a child.

    Thank you for your response.

    Thanks and Regards
    Arivazhagan Sekar
    +968 959 11 498

  • #762970


    As per my understand the post the output should be below format right?

    ParentId ChildId
    1 2
    1 3
    1 4
    2 5
    2 6
    3 7

    If you are expecting the above format then Use PrimaryKey and ForeignKey relation between the tables.

    If my understanding is wrong then please give some sample of your desired output so that we will help you better.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

Sign In to post your comments