Data Model for a popular/basic type of social app
1
vote
0
answers
87
views
I am trying to learn about Google Datastore and creating a basic application to have some practical experience with it opposed to just reading the docs. I would like to create a basic social application where users can send messages to their friends and view the messages their friends have sent them.
My Basic App Requirements:
**Users Section:**
- A user registers to the app. The user can then log in by using their
username/email and checking if the password is correct and the status
must be VALID and not something like DEACTIVATED.
- A user can also be deleted. When a user is deleted If a user deletes
their account their references from all their friends need to be
removed and messages needs to be removed (or hidden). This is
obviously expensive.
*Users Model*
-username (need to be able to make equality searches on this field. e.g select * from kind where username = 'Bob') (index)
-email (need to be able to make equality searches on this field. e.g select * from kind where email = 'Bob@gmail.com') (index)
-fullname
-password
-status (need to be able to make equality searches on this field. e.g select * from kind where status = 'DEACTIVATED') (index)
-time_created
**Friends Section:**
- A user can query to find all of their friends (Accepted and Pending).
- A user can add another user to be friends (make sure relationship
doesn't already exist and make sure user exists).
- A user can
accept/reject a friend request.
- A user may have a max of 100 friends.
*Friends Model*
-User1 (index)
-User2 (index)
-status
-time_created
**Messages Section:**
- A user may see all the messages they sent/received to/from confirmed friends
- A user can send a message to a confirmed friend.
- A user may receive a message to a confirmed friend.
- Messages will be paginated in the application so 10 messages at a time come up sorted by the newest coming first.
*Messages Model*
-from (need to be able to make equality searches on this field. e.g select * from kind where from = 'Bob')
-to (need to be able to make equality searches on this field. e.g select * from kind where to = 'Bob')
-msg
-time_created (need to sort on this so that the newest messages come first)
My plan is to make 3 kinds: Users, Friends, and Messages (each would have the attributes shown above).
Some concerns I have is regarding atomic operations. For users, would it be wiser to create a one way relationship between friends or two-way. If two-way, say the friends request gets accepted or rejected, would the application be atomic? Another question is if a user gets removed, how best to handle this to be inexpensive and keep data consistent.
Is this a good model for this basic/popular type of social application? I am very interested to hear of anyone suggestion how they would implement this basic application and the reasons why.
Cheers!
Asked by user2924127
(305 rep)
Dec 6, 2015, 07:07 PM