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

  • Home
  • SEARCH
  • 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 633533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:11:48+00:00 2026-05-13T20:11:48+00:00

I am making a database for a program where i am supposed to model

  • 0

I am making a database for a program where i am supposed to model some relations in the family.
ex:
X is father to Y , Y is son to X

So , i have a Members table with all info about each member so i thought about making a many to many relation between the Members table and itself so that the Member_Member bridge table will be having the columns “FK_FromID , FK_ToID” as composite key (is this correct ?) and “FK_RelationType” as a foreign key to RelationTypes table which will have the relation type “Father,mother, son,daughter” , and two relations going as one to many from the Members table to these two foreign keys

My problem is : when deleting if i choose cascading then i will make cycles because if i delete a member then there will be two delete passes to related records in Member_Member bridge , knowing that in the program whenever i insert a father relation i will insert a son relation as well in the Member_Member table , is there a way or a workaround possible to enable cascading so that whenever i delete a member i will delete the related records in Member_member regardless of being recorded in either a to or a from foreign key column

So, i don’t know what to do , is this a correct design in the first place or what ? , what should i do about cycling , also what do you think a better design for the same problem should be knowing that i need to specify what kind of relation between the two parties

Thanks a lot for any help , and sorry for bad english
Bishoy

  • 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-13T20:11:48+00:00Added an answer on May 13, 2026 at 8:11 pm

    SQL does not handle “network” problems like this very well.

    The member-member bridge table is a terrible name. It’s a “member-parent” (or “parent-child”) bridge. Bridge tables should not have a “composite key”. Bridge tables have a surrogate key (just a sequential number) and a pair of FK references to other tables. The two FK’s should have names like “member” and “parent” to make it perfectly clear what the relationship is in this table.

    Everyone has a parent. Not everyone has children. Some parents will not have parents in this database; they’re the “top parents”.

    It’s easiest if the top parents have rows in the parent-child bridge with a parent FK of NULL. That way you avoid super-complex outer-joins — every member has at least one member-parent row; ideally two.

    You will find many “cycling” issues since relationships are transitive.

    Note that you can’t — in a single standard SQL query — find all members of the family, or all parents back to the top of the family, or all children and grand-children. There are SQL extensions that make this possible, but the standard doesn’t handle it well.

    The cascading delete doesn’t work out well because the relationships in a family are directed in two ways (parent to children, child to parents), but SQL only has one kind of direction (FK reference).

    You can try to assure that every member MUST have at least one (and at most two) rows in “member-parent” and the delete of a member deletes the two rows in “member-parent” and the keys have the proper names, you might make parts of this work.

    Note that when you delete a member, this will break their parent relationships. You delete the member-parent row. That’s good. What about their children? The other rows which have member-parent referring to this deleted parent are now broken. What does this mean? What should be done?

    There’s no standard answer. Removing rows from a connected graph leaves elements
    unconnected. You have to work out some sensible rules for that.

    Since SQL does not do this well, all designs will seem to have problems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 311k
  • Answers 311k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I get the impression that iterparse is what you want.… May 13, 2026 at 10:24 pm
  • Editorial Team
    Editorial Team added an answer It's not a problem with the CSS or the server… May 13, 2026 at 10:24 pm
  • Editorial Team
    Editorial Team added an answer There are several ways to do this but the easiest,… May 13, 2026 at 10:24 pm

Related Questions

My company has recently put up a demo database on his remote servers to
I'm making a WPF application that is comprised of Screens (Presenter + View). I
I'm developing an ASP.NET application with VB, and using SQL Command and Connection in
I am trying to rearchitecture a program which runs on Win CE 5.0 devices,
EDIT: See my answer below for the hotfix. ORIGINAL QUESTION: In setting up for

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.