Relational Database Query (iOS)

Hey,

I’m trying to understand relational database data retrieval with Backendless. I was wondering if there are any video tutorials explaining this topic further?

I have been reviewing this link. https://backendless.com/documentation/data/ios/data_relations_retrieve.htm

Does Backendless have a “Create View” option where I can summarise data then call it?

I have 5 levels of relational tables. All which have 1 to Many relationship. Just trying to display the data at the lowest level i.e. CourseCategory is, well, challenging.

  • Pilot
    • Enrolment
      - Course
      - CourseCategory
      - Competency

Perhaps, I’m overthinking this, but its how I have done in for numerous other languages. Just getting myself a tad confused.

It sounds like you’re overthinking it. Try to approach it from the user experience perspective. It is rarely the UI needs to have ALL of the data at once.

Btw, views in the classical SQL sense are not supported.

Regards,
Mark

Hi Mark,

Yeah I thought was the case, the issue is I really do need to keep some form of relationships…fortunantly its at the very beginning so might look at a different way of doing this and move away from relationships.

Thanks Mark,
Jeremy

Hey,

I actually got it working. I found that the details were buried in array’s. It also helps when you import the corresponding tables oops. However, need a little advise on how to extract the value from the nsmutablearry.

Happy to shot this over to stack overflow, but thought I would ask here first hope that is okay.

Below is my code that where i’m extracting information from backendless.

        BackendlessDataQuery *query = [BackendlessDataQuery query];

        query.whereClause = [NSString stringWithFormat:@"PilotFirstName LIKE \'%%%@%%\'", partialName];

        BackendlessCollection *collection = [backendless.persistenceService find:[Pilot class] dataQuery:query];

        

        NSLog(@"Results From Query %@",collection);

        

        if (collection.data.count == 0) {

            //reset the NSArray to be blank because no values came back

            studentRecordData = [[NSMutableArray alloc]initWithArray:collection.data];

        }

        else

        {

            studentRecordData = [[NSMutableArray alloc]init];

            

            for (Pilot *pilotLog in collection.data)

            {

                

                pilotFirstName = pilotLog.PilotFirstName;

                pilotLastName = pilotLog.PilotLastName;

                contactNumber = pilotLog.ContactNumber;

                ARN = pilotLog.ARN;

                RAA = pilotLog.RAANumber;

                StudentObjectId = pilotLog.objectId;

                StudentEnrolment = [[[collection.data valueForKey:@"Enrolment"]valueForKey:@"Course"]valueForKey:@"CourseName"];

                

                NSLog (@"R: %@", [[[collection.data valueForKey:@"Enrolment"]valueForKey:@"Course"]valueForKey:@"CourseName"]);

// for (Pilot *isEnroled in pilotLog.Enrolment) {

// StudentEnrolment = isEnroled.Enrolment;

// }

                [studentRecordData addObject:[[StudentRecord alloc]initWithpilotFirstName:pilotFirstName andpilotLastName:pilotLastName andcontactNumber:contactNumber andARN:ARN andRAA:RAA andStudentObjectId:StudentObjectId andEnrolment:StudentEnrolment]];

            }

This sorta works and puts everything into a NSMutableArray. Below is the actual data dump.
(

(

        RPL,

        CPL,

        PPL

    ),

Because its going into a UITable I need the array of values to be turned into a NSString so I can display it. That’s it. The below image is what is coming back from Backendless. As you can see I need the values RPL,CPL, PPL, or what ever else comes along
http://support.backendless.com/public/attachments/cc4c342a806f0195847fe2d7981f119a.png</img>

Coming back to Objective C is like trying to figure out how to walk again.

Any advise would be great.

Thanks in advance!

Hi Jeremy,

Helping you to build your application is not a free support option, according to our Support Policy.
In case you find a bug in SDK or on the server, please feel free to report it.

Hi Sergey,
I wasn’t after free support as I’m still trying to understand how Backendless works coming from Parse. But I can see how I asked the question how it may have been conceived. I’ll be careful how I ask the questions and keep it in line with the Support Policy. Furthermore, any questions that are in objective C nature outside of the scope of backendless, I’ll post on other forums. All good.

I actually worked out the issue afterwards based on marks comments. I posted what I had in the event anyone else was having the same issue.

Thanks again for the heads up.