Database Design – Linking Parent and Child Relationships

database-designrelationships

Currently i have requirement saying user from an UI creates there own forms which has types textbox,choicegroup etc..
Does anyone have a any idea on how to architect the database to store all data?
If user want to link form1 to form2 etc.. how will these data links stored in database?

For example, parent1 has child1 & Child2, flow can be like this parent1->child1->child2.(In 1 single line how will parent child relationship need to be maintained in database tables)

Best Answer

This abstract of table can help u, which I am using in my project.

Parent : Equipment

Child : Component

Sub Child : Sub Component

Table 1 Columns
id(PK) | Parent_Equipment_Id | Componentid | component Order

Table 2 Columns

id(PK) | Parent_Component_Id | Sub_Component_id | sub_component_Order

There can be one to many relationship between your parent and child table, so it is very complicated to use single table

Also you need to create 3 Entities for Repository

  1. Abstract ParentEntity
  2. ChildEntity extends ParentEntity
  3. SubchildEntity extends ChildEntity

I hope it will help you to normalize your database.

Related Topic