Reputation: 10784
I have an entity called Workout with the following attributes:
workoutDate
runningTime
ellipticalTime
stairMastersTime
benchPressWeight
I'm requiring users to create an account before using the app in the following format'@Username'. I'm using stackmob for hosting. Once the user is created, I would like to save each 'Workout' object the user creates under the user's profile for later fetching.
Question 1: How do I avoid having one database with all the users objects saved in one place? Do I need to create an entity for each username that'll act as their profile and save each 'Workout' objects under their profile? I would like the user to be able to fetch these objects based on dates. i.e. From January to June 2013?; last 6 weeks?; and have the objects displayed in a UITable.
Question 2: I would also like the user to send these objects to another user. i.e. Send the details to @Trainer. I believe I will be using Push notifications to inform the recipient user that another user has sent them an object -- kind of like facebook notification. @Trainer at that point can download the received object and view it, edit it, or delete it. etc.
What's the best way to accomplish both of these tasks without jeopardizing performance?
Can someone please point me in the right direction/ Thank you!
Upvotes: 0
Views: 162
Reputation: 10201
Question 1: How do I avoid having one database with all the users objects saved in one place? Do I need to create an entity for each username that'll act as their profile and save each 'Workout' objects under their profile? I would like the user to be able to fetch these objects based on dates. i.e. From January to June 2013?; last 6 weeks?; and have the objects displayed in a UITable.
As for my understaning. You will have to normalize your database. Database should have following
You should create one entry for each user. Relation would be User<-->>Workout, the User can have many workouts(one to many), but workout will have one user( one to one relationship). Since workout has workoutDate you can easily pass a timeReference and ask for workouts mapped to a user.
Question 2: I would also like the user to send these objects to another user. i.e. Send the details to @Trainer. I believe I will be using Push notifications to inform the recipient user that another user has sent them an object -- kind of like facebook notification. @Trainer at that point can download the received object and view it, edit it, or delete it. etc.
You can create events mapped between a user to user with workouts. You can pass the unique identifier of Event along with Push Notification. Using this unique identifier you can fetch the workouts send to the user.
A user has a role, and the role has permissions. They should be allowed to modify workout based on permission.
Since you have a remote user datbase, by using coredata you can persist and fetch only the delta of what has been changed. Or if you can afford to fetch data everytime you can use in memory store to store your data well structured and edit them accordingly.
Upvotes: 1