# Core Data model for test-taking iOS app

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 per Test taken
• Each Test has one User
• 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 and User_Answers necessary?
• I could, in theory, have a relationship directly between Test andQuestion? Test -->> Question. I would like to know which is better.

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)removeQuestionsObject:(Question *)value;
- (void)removeQuestions:(NSSet *)values;

@end


@class Answer, User;

@property (nonatomic, retain) User *user;
@end


Test_Questions and User_Answers are not necessary since they do not hold any attribution and are one-to-one relationships with Test and User, respectively. It is always suspect when you have a plural table name.
However, the model fails to support the ability of a User to take multiple Tests. To fix that, User.testTaken should be replaced by User.testsTaken and made into a one-to-many relationship with Test.
Also, it seems a bit odd that a Test can only be taken by a single User, but if that's your requirement, then so be it.