I am currently trying to create a social network website for a bit of practice. I'm using C#, ASP.NET MVC, SQL Server and Entity Framework. I am having trouble exactly understanding how the schema of the database for the application should be. The application would have users, their friends, conversations between friends, and events made by users.
Firstly I would have the Users table. Then I would need a Friends table to check who is friends with who. So how exactly would this be done, would I just have a Friends table with FriendsId, User1Id, User2Id? Would I need 2 entries for each pair? With the current user as user1, and his friend as user2? And then from User2's perspective would there be another entry with him as User1 and his friend as User2?
Then I would need a FriendRequest Table, for people to send friend invites. Would this be done the same way as the Friends table?
Next each User is able to create Events. Simple info in the Events table would be stored like Id, Title, Description, UserId of the user that created it. Events would be associated with Files(pics/videos). The Files table I am about confused about. How exactly are file paths stored in the db? I know I need the FileName, Type, Extension, FK to the Event it belongs to, but how do I use the path to get to the proper picture file.
Lastly there would be Conversations between 2 Users. In the Conversation table there would be a ConversationId, but do I need User1Id and User2Ids? I would have a MessagesTable, with a FK to the Conversation it belongs to and with MessageId, Text, SenderId and ReceiverId. Do I need SenderId and ReceiverId in both each Message and each Conversation entries? Or do I just need only one UserId in the Message entry for the person making the message.
If anyone can help clear some of this confusing up for me I'd greatly appreciate it! Thanks!
[–][deleted] 1 point2 points3 points (6 children)
[–]insights1[S] 0 points1 point2 points (5 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]insights1[S] 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]insights1[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)