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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:49:02+00:00 2026-06-11T16:49:02+00:00

My model have 2 Entity (Category and News) with many to many relationship: (It

  • 0

My model have 2 Entity (Category and News) with many to many relationship: (It mean a category may have many news and a news article may belong to one or more Category).

Below is my design:

  • Entity 1:

Category (attributes: categoryID, title, show, position) and a relationship with News Entity called “news”.

“news” relationship has destination is “News”, inverse relationship is “categories”, type to-many relationship and delete rule is cascade.

  • Entity 2:

News (attributes: newsID, quote, content, link) and a relationship with Category Entity called “categories”.

“categories” Relationship has destination is “Category”, inverse relationship is “news”, type to-many relationship and delete rule is nullify.

Object graph look like this:

News <<————–>> Category

My question is:

1> Is my designed model is good ?

2> Arcoding to my designed model, if I delete a News object from it context example like:

id newsObjectToDelete = ….
[managedObjectContext deleteObject:newsObjectToDelete];

Does Category object that newsObjectToDelete belong to automatically remove newsObjectToDelete from NSSet of relationship “News”.

3> If I want to constraints that a “News” must belong to at least one “Category”. How to implement that constraints

Thank in advance. Sorry for poor English

  • 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-11T16:49:03+00:00Added an answer on June 11, 2026 at 4:49 pm
    1. It’s tough to say whether or not this is a good fit for your app, but it looks like a pretty standard relationship.

    2. If you delete an object, it is automatically removed from all Core Data relationships. Don’t worry about a dangling reference to some deleted object, Core Data handles that for you.

    3. Core Data can really only generate an error (and blocking the save) or take some automatic action during the save. You can do either of the following:

      • In Your Data Model: Using the data model editor, uncheck “Optional” for this relationship, and/or set the “Minimum” count to 1:

        Core Data 'Data Model Inspector' Screenshot

      • In Your “News” Subclass: If you need more fine-grained control and/or error reporting, you can check this during validation (to generate an error) or maybe take some automatic actions during the save process.

      Note that using validation (either in the model or in your code) is only going to help during the development and debugging processes – calling -save: on the managed object context will fail, returning NO and generating an error. This should be a last resort, and really just there to keep bad data from getting into your persistent store. A validation failure like this tells you that some other part of your code is wrong and generating bad objects.

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

Sidebar

Related Questions

Essentially what I have is an entity class (Article) and one article may belong
I have a core data model that has a one to many relationship, there
I have a model, where I have an entity called Category. This Category has
I have a entity called Category and a entity called item. Category may have
I have a many-to-many association between 'Category' and 'Product' entities in my Entity Framework
I have two PHP model classes named Category and Item. A Category may have
I have the following model I am able to sort the Category Entity using
I have two objects. @Entity class Person extends Model { ... @OneToOne Category category;
Lets say I have entities Article, Page and Category. I want entity Article to
In my business model I have Entity class (IPoint interface ) that has a

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.