문제

I am developing one social networking website. Right now I am using mysql for data storage. Now I have to move on nosql database (I prefer ElasticCache or DynamoDb (amazon service) ). But I am confusing about data modeling. In mysql I have following data structure.

***UserMst:***
UserID
UserName
UserEMail
BirthDate
.....

***FriendMst***

FriendID    (Pk)    
UserID      (UserID)
HisFriendID (User's friend id)
Status          

***Notification table***

NotifyID    (Pk)
UserID      (UserID)
HisFriendID (User's friend id)
NotifyDate  (Notify date)

How do I model this for nosql database? can somebody help me?

도움이 되었습니까?

해결책

NOSQL is a collection of different data platforms, so it depends on which you choose. You have specified DynamoDb, and ElasticCache which supports Memcached and Redis. You are essentially dealing with key-value stores, and one way to support your use case with a key-value store is:

1) Have a document-like structure for the user, comparable to a UserID key and a set of fields that are roughly similar between documents: username, email, etc. This would be a table in DynamoDb, a document in MongoDB, or a static column family in Cassandra.

2) Your FriendMst would be saved as a UserID key and an array of items with FriendUserID and status. With a document database like MongoDB, this could be embedded in the User document or stored in a related document. In Cassandra, this could be a dynamic column family. Something similar might work for the notifications, depends on your query use cases.

Having said all that, it might be good to consider a graph database like Neo4J. They have been designed specifically for these kinds of network use cases, and could easily return friends of friends, or find notifications by your friends, or rank recommendations from friends and their friends, etc.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top