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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:13:41+00:00 2026-05-17T19:13:41+00:00

I have a core data model, using the database store, that contains entities with

  • 0

I have a core data model, using the database store, that contains entities with classic parent/child relationships. Each parent has a number of children, each child a single parent, creating a multi-level hierarchy.

What I would like to do is use a predicate in a fetch request to return a list of all the entities between a given entity and the root.

If I was doing this in code I’d work my way up the ‘parent’ chain till I hit the root entity, but I’d like to do this in a predicate so that the search stays ‘in the database’. This will be part of a search an so needs to be relatively fast.

Is this possible?

  • 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-17T19:13:42+00:00Added an answer on May 17, 2026 at 7:13 pm

    Predicates are to hardwired to transverse an unknown number of object in a relationship graph. You have to tell it concretely what entities and relationships to traverse. You can’t say, “traverse relationship so-and-so until you hit a nil.”

    Premature optimization is the root of all evil. I wouldn’t worry about the speed of traversing relationships in live objects. Core Data is much faster than you might expect at such things. To optimize in this case, set to fetch as faults so no data is loaded only relationships and I don’t think you will have speed issues.

    As an aside, watch your nomenclature, entities are to managed objects as classes are to instances. Entities are abstract, managed objects concrete. Entities are attributes only of the data model. In this case for example, you might have only one self-referencing entity in the data model which could be used to create a graph of millions of managed objects.

    You can find parent entities just like you find super classes but that wasn’t actually what you were asking about.

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

Sidebar

Related Questions

I have several Core Data model version that I have added to my .xcdatamodeld
Say I have a core data model with a few entities and, throughout the
In my core data model I have a Person entity that has a to
In my Core Data model I have two entities: List and Patient. List has
I have set up a Core Data model that includes an entity, Item with
I'm using Core data in an iOS project. I have the data model setup
I have a core data model with some entities set up. I have set
Im using a Core Data model for my iPhone app. I have been looking
I'm using core data and I have a simple two-entity model. My navigation controller
I have my app using core data with the data model below. However, I'm

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.