Home > Enterprise >  designing SQL table
designing SQL table

Time:01-06

I have a database of the growth rates of children. Every child is examined more than once (3-5 times), and weight and height measurements are taken. The examination date is also recorded.
Moreover, there is also data about the mothers of the children, noting that each mother can have more than one child.

What is the best way to arrange the data in SQL tables?

  • I think the relationship between the children and the examinations is "one to many" (a child is examined a few times).
    but I'm not sure if the examinations and the children should be on separate tables because I don't have data on the children that do not relate to an examination (for now).
  • The relationship between the mothers and children is also "one to many" (one mother could have many children).

Should I then use three tables or only two? I currently have an id to use as keys for each child and mother. Thank you!

CodePudding user response:

I’d say you need three tables, parent, child and examination, to accurately model the entities as you describe them. If the model only had parent and examination entities, each parent would have many examinations, with the child being one of the examination's attributes. That might be workable, but it doesn’t model the entities accurately, and could lead to problems if attributes were added to the child entity at some point. If the child entity has no attributes besides its id “for now" so be it.

  • Related