I'm building an iOS app for test-taking and I want to be sure of my model before proceeding.
I found this post very helpful and tried to implement a simplified version for Core Data.
Here are some of my assumptions:
- Each
User
can take multiple tests - Each
User
has one set of answers perTest
taken - Each
Test
has oneUser
- Each
Question
has many answers
Here is my Core Data model:
Overall, what do you think of my database schema? Is it sufficient to handle a simple test-taking app?
- Also, are
Test_Questions
andUser_Answers
necessary?- I could, in theory, have a relationship directly between
Test
andQuestion
?Test -->> Question.
I would like to know which is better.
- I could, in theory, have a relationship directly between
Here are my model headers for Test_Questions
and User_Answers
:
Test_Questions.h
@class Question, Test;
@interface Test_Questions : NSManagedObject
@property (nonatomic, retain) Test *test;
@property (nonatomic, retain) NSSet *questions;
@end
@interface Test_Questions (CoreDataGeneratedAccessors)
- (void)addQuestionsObject:(Question *)value;
- (void)removeQuestionsObject:(Question *)value;
- (void)addQuestions:(NSSet *)values;
- (void)removeQuestions:(NSSet *)values;
@end
User_Answers.h
@class Answer, User;
@interface User_Answers : NSManagedObject
@property (nonatomic, retain) User *user;
@property (nonatomic, retain) NSSet *userAnswersSet;
@end
@interface User_Answers (CoreDataGeneratedAccessors)
- (void)addUserAnswersSetObject:(Answer *)value;
- (void)removeUserAnswersSetObject:(Answer *)value;
- (void)addUserAnswersSet:(NSSet *)values;
- (void)removeUserAnswersSet:(NSSet *)values;
@end