Hi, I am trying to design a website like Facebook, where user will have friends and will have wall where they can see there friend's updates etc. While designing it on GAE i got confused with what will be the best approach like data duplicate, data read time or data write time etc
Friend's Design: I thought there will be User and User will be friend with another User. Class User{ Key id; String name; String email; ...etc } Now i definitely can not have owened relatioship with Friends means I can not have List<User> friends in my User Class as it will not be same domain(User) data, so i thought ok i will have List<Key> or List<Long> User Ids as Friends Class User{ Key id; String name; String email; List<key> friends. ...etc } And confusion/problem begins. First a Friendship is supposed to be from both side, so it should be defined only once but in this design both Friends will have each other's id in there friend list. Basically its not a typical relationship. What if i want to keep friendship info like when it started, who introduced etc. Then i may need to create a new Friend class with two fields as user1Id and user2Id and query this class with user1Id=<userId> or user2Id=<userId>. But not sure about this approach. Second i am doing data duplicate(but i am fine with it if it can be proved as best solution). Third: I am showing one user's profile and want to show his friends on one page, so first i need to get the User and its Friend List<Key> then i need to search User for each and every Id to get each user's data(like name.profile id and photo). For me it seemed bit longer process.Not sure how queries will perform. Pseudo Code will be like this > Get Logged In User > Loop through friends field >Begin get User for each iterated Friend Id. //and if we want to show how many friends that user have, then i will be accessing friend list for each friend,so there will be lot of data read from database. >End put all data in jsp to compile and show it to user. Other design problem related to wall like Facebook wall/profile, Lets say i have UserActivity class to keep track of User's Activity and that can be owned by User, so User class can look like Class User { Key id; String name; String email; List<Key> friends//assume we are going with this kind of design List<UserActivity> activities } Class UserActivity { Key id; String statusMessage; Date time; User user; } Now i want to show all activities of a user to him/her order by time(recent first/on the top). Now again i see one way of doing it as get all the Friend's id from List<Key> friends field, query all User data then go through UserActivity and get all data in memory and sort it out. This seems not a good option to me. How can i solve this problem efficiently and design a good solution. Thanks in advance Ravi. -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.