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 8119653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:51:46+00:00 2026-06-06T04:51:46+00:00

Say, we have 2 entities : Parents and children . When a parent is

  • 0

Say, we have 2 entities : Parents and children.

When a parent is deleted, then all the children are erased too.

Great.

Now we have entities called lover.

Each individuals can “love” many other individuals and be loved by many.

What happen if an individual deleted?

Does cascade delete:

  1. Don’t work at all?
  2. Delete you when the last person that love you is deleted?

Or what?

  • 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-06-06T04:51:48+00:00Added an answer on June 6, 2026 at 4:51 am

    I think, that you shouldn’t use cascade with to-many this way, because, as it deletes all the lovers of the object you delete, it may go further and further and delete the whole database.

    So the better approach for you is to have a intermediate (“join”) entity, for example, loverInfo.
    Here’s, how the Apple suggest you to do that, based on the friends relationship.

    A common example of a relationship that is initially modeled as a many-to-many relationship that’s the inverse of itself is “friends”. Although it’s the case that you are your cousin’s cousin whether they like it or not, it’s not necessarily the case that you are your friend’s friend. For this sort of relationship, you should use an intermediate (“join”) entity. An advantage of the intermediate entity is that you can also use it to add more information to the relationship—for example a “FriendInfo” entity might include some indication of the strength of the friendship with a “ranking” attribute. This is illustrated here

    FIgure 3

    In this example, Person has two to-many relationships to FriendInfo: friends represents the source person’s friends, and befriendedBy represents those who count the source as their friend. FriendInfo represents information about one friendship, “in one direction.” A given instance notes who the source is, and one person they consider to be their friend. If the feeling is mutual, then there will be a corresponding instance where source and friend are swapped. There are several other considerations when dealing with this sort of model:

    • To establish a friendship from one person to another, you have to
      create an instance of FriendInfo. If both people like each other, you
      have to create two instances of FriendInfo

    • To break a friendship, you must delete the appropriate instance of
      FriendInfo.

    • The delete rule from Person to FriendInfo should be cascade. If a
      person is removed from the store, then the FriendInfo instance
      becomes invalid, so must also be removed.
    • As a corollary, the relationships from FriendInfo to Person must not
      be optional—an instance of FriendInfo is invalid if the source or
      friend is null.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say we have two entities:teacher and student. each teacher has multiple student. Now I
Say I have entities organized in a hierarchy with Parent being the root entity
Say I have 3 entities Grandparent , Parent , and Child . Grandparent -
Let's say I have entities a, b and c all of the same type,
Lets say i have 2 Entities, User and Address. Each User has to have
Let's say I have two entities: Group and User. Every user can be member
I have two entities say Customer and Order which exist on their own and
Say I have a core data model with a few entities and, throughout the
So lets say we have a couple of entities we want to persist using
Say, I have following entities: @Entity public class A { @Id @GeneratedValue private Long

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.