Question

I have created an entity called Subject. Inside the Entity I have placed all the attributes that I only need once for each entry created. Then I have created homework enitity and linked it to the Subject class. My question is am I correct in thinking that I can create multiple homework objects linked to each Subject object I make in my app.

For instance I make a Subject entry with subject='Maths' then in through the Maths entry able to add lots of different homework entries.

enter image description here

Was it helpful?

Solution

The relationship between Homework and Subject is currently a one-to-one relationship (as seen that you have 1 arrow pointing to the word homework and 1 arrow pointing to newRelationship). To add multiple homework objects to a subject, change the relationship to a one-to-many relationship.

Schedule *schedule;
Homework *homework;

for (Homework *homework in schedule.homework) {
    NSLog(@"homework = %@", homework);
}

[schedule addHomeworkObject:homework];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top