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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:31:52+00:00 2026-05-17T02:31:52+00:00

I know Core Data is not a database and there are many differences. Is

  • 0

I know Core Data is not a database and there are many differences. Is this one?

In a database, I would commonly have the following

A ->> B ->> C

“A” has many “B” which has many “C”

The query, “Give me all A’s which have c.attr = ‘X’ is easily written like:

select * from a, b, c where a.id = b.aid and b.id = c.bid and c.attr = 'X'

In Core Data, I would like to do the same, but using a predicate like:

NSPredicate *predicate = 
  [NSPredicate predicateWithFormat:@"ANY bs.cs.attr = %@", "X"];
[frequest setEntity:entityA];
[frequest setPredicate:predicate];

Doing this results in the error:
‘NSInvalidArgumentException’, reason: ‘multiple to-many keys not allowed here’

Am I correct to interpret to mean there is a limitation on what databases call multi-table joins?

I googled around and couldn’t find a definitive answer.

My current solution to this query looks like:

NSPredicate *predicate = 
  [NSPredicate predicateWithFormat:@"ANY cs.attr = %@", "X"];
...
NSArray *bs = //execute fetch
for (B *b in bs) {
  //add b.a into an array
}
//return array

Is there a better way? Thanks in advance for the consideration.

  • 1 1 Answer
  • 3 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-17T02:31:52+00:00Added an answer on May 17, 2026 at 2:31 am

    Your going about this backwards.

    First of all, you don’t need the linking ids in Core Data because all related objects are already linked by the relationship. This means constructions like where a.id = b.aid and b.id = c.bid aren’t needed at all.

    Secondly, you generally set the fetch entity for the entity that receives the defining test. In this case, that is c.attr="X"So, you set your fetch entity to C and your predicate should look something like:

    NSPredicate *p=[NSPredicate predicateWithFormat:@"attr=%@",xValue];
    

    This will return an array all the C instances that meet the test. Then finding any particular B or A is just a matter of walking the relationship for each C.

    If your inverse relationship is to-one e.g A<->>B<->>C, the you just ask each C for the value of the b.a so:

    AObject *anA = aCinstance.b.a;
    

    It’s important to remember you are not dealing with tables here. You are dealing with an object graph. You set the fetch to a particular entity and then walk the filtered entities’ relationships.

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

Sidebar

Related Questions

I have created a core data database in one application which involved sucking out
I have a core data database which has (for now) 2 entities Product and
I would like to sort the data of a core data NSSet (I know
I know questions like this have been asked numerous times, but not quite this
I have the following tables in Core Data: Cinema (movies) Movie (title, times) DateTime
I'm working on an iOS app. I have a Core Data database with a
I have an iPhone app with a Core Data database containing a list of
I have an entity that stores information about my photos in core data. One
I know how to sort Core Data objects in a tableview by NsDate, but
I am using the core data in my application. I know how to insert

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.