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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:20:44+00:00 2026-05-28T01:20:44+00:00

I have been learning CoreData to use it in my application and have some

  • 0

I have been learning CoreData to use it in my application and have some problems generating sql model.

I would like to have two entities (at least). One is Items, other is History.
Logic: every history entity should have none or many Items. Items shouldn’t duplicate each other – uniques.

How can I model this in Xcode? Do I need a linking entity like “History2Items”?

I have been struggling this for a while but I can figure it out the proper solution.

Any help?

UPDATE:

I have made this model:

CoreData model

For fetching data I used relationship for prefetching:

[request setRelationshipKeyPathsForPrefetching:[NSArray arrayWithObject:@"item"]];

And that’s how I get Items for each History:

History *history = [self.historyArray objectAtIndex:indexPath.row];
NSMutableArray *items = [NSMutableArray arrayWithArray:[history.item allObjects]];

Just looped over items array to get each Item.

It’s that easy. Thanks to @Ashley Mills.

  • 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-28T01:20:45+00:00Added an answer on May 28, 2026 at 1:20 am

    Create Item and History entities and connect them as follows:

    enter image description here

    If an Item can belong to more than one History, change the relationship from one-to-many to a many-to-many.

    You only need a linking entity if you intend on ordering the items for a history by an index, as each item could have a different index for a given history. If you’re ordering items by date for example, no linking entity would be required.

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

Sidebar

Related Questions

I have been learning to use Emacs for a little while now. So far
I have been learning C++ with some books from school that are from the
I have been learning python for some time now. While starting this learning python
I am learning to use Core Data. I have created a data model etc
I have been learning about various functional languages for some time now including Haskell,
I have been learning some of the more detailed loopholes of JS here and
I have been learning Python by following some pygame tutorials . Therein I found
I have been learning about indexes in Oracle SQL, and I wanted to conduct
I have been learning C# for the past few days for use with ASP.NET
I have been learning PHP for some time now and I wanted one clarification.

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.