Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 970219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:46:14+00:00 2026-05-16T02:46:14+00:00

I am trying to create a proper parent/child relationship within my data model. I

  • 0

I am trying to create a proper parent/child relationship within my data model. I have a typical one to many relationship between the parent and children.

I am wondering if I have parents that know about their children, is it

  1. ever acceptable, and
  2. a good idea

for each child to specifically know about its parent?. (a child can only have one parent in my case)

parent      
-------------
PARENT_ID
OTHER_COL
...

child
-------------
CHILD_ID
PARENT_ID    // <-- Should this column be here?
OTHER_COL
...

parent_has_children
--------------------
PARENT_ID
CHILD_ID

The advantage I see for having the parent column in the child, is for easily retrieving the parent from a child. But, is this just lazy design?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:46:14+00:00Added an answer on May 16, 2026 at 2:46 am

    TL;DR

    Re the question:

    child
    PARENT_ID    // <-- Should this column be here?
    

    Yes, and if a foreign key constraint is added from child.PARENT_ID referencing the parent column parent.PARENT_ID, the integrity of the parent-child relationship will be enforced.

    Should table parent_has_children exist?

    No, a link or union table like this is used to model a many-many relationship. A many-many relationship between tables P and C would imply that the same C row can simultaneously associate many P rows, and vice-versa. That is clearly not a parent-child relationship.

    Modelling the 1-to-many relationship

    If the relationship is 1 parent to many children (i.e. the same child can only belong to exactly one parent), then the standard modelling approach is to reference the Parent table from the Child table, via (one of) the Parent’s key columns, usually the Parent’s Primary Key (PK). At the same time, it is also a good idea to Foreign Key (FK) constraint on the reference column (child.PARENT_ID) to encourage the RDMBS to enforce referential integrity across the relationship:

    parent      
    -------------
    PARENT_ID PRIMARY KEY, // PK for the parent table
    OTHER_COL
    ...
    
    child
    -------------
    CHILD_ID PRIMARY KEY,  // PK for the Child Table
    PARENT_ID              // <-- Should this column be here? = Yes
    CONSTRAINT FK_ChildParent FOREIGN KEY(PARENT_ID) REFERENCES parent(PARENT_ID)
    

    The OP’s additional many:many table parent_has_children is redundant, as it will have exactly one row per child, and it will soon become a burden to keep this table in sync with rows added / removed from the other tables (as failure to keep this synchronized will result in confusion / contradiction in the integrity of the relationship).

    Re : How do parents know about their children?

    Child records for a given parent can be found using a simple query on the child table filtered on the parent foreign key column:

    SELECT ... 
    FROM child 
    WHERE PARENT_ID = myParentId;
    

    As this is usually a common query, it is always a good idea to ensure that the foreign key child.PARENT_ID is indexed – some RDBMS versions do this for all foreign keys by default.

    CREATE INDEX IXFoo on child(PARENT_ID);
    

    If you have an entity model (e.g. for an ORM) in an application representing these tables, the parent entity will generally have a collection containing its child instances, and on the child entity, the scalar foreign key child.PARENT_ID ‘column’ is either dropped entirely, or replaced with a reference to an instance of the parent:

    class Parent
    {
        ParentId,
        Child[] Children,
        // ...
    }
    
    class Child
    {
        ChildId,
        Parent Parent, // Optional, allows bidirectional navigation
        // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to create a proper Restart feature within my app, which doesn't
I'm trying to create proper header files which don't include too many other files
I'm trying to create a secure webservice (that provides simple database data) with PHP
So I am trying to create an RTE environment. I have a content editable
I'm trying to create proper wsdl based soap request but with no success, here
Trying to create a regex that ignores a proper integer ( 1 , 5
I'm trying to create a spacing between an element and its outermost border. (EDIT:
I am trying to create a method that finds and replaces a string within
I am trying to create a proper regular expression to find all anchors in
I am trying to create a 3D function plotter for iOS. I have succeeded

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.