Monday 23 April 2018

Database Questions

I'm currently working on my first large full stack web project. However, I'm running into a problem where I believe I made some mistakes with how I wanted to store when I was still working things out, and even if my data is small enough that it probably doesn't matter, I'd still like to know how I should be doing things for the future, even if it isn't worth uprooting my problems to fix right now.Currently I'm using MongoDB, but I'm pretty confident that I should have used a relational database. When I'm writing schemas I feel like I'm trying to emulate SQL. I have no previous experience in any database besides mongo, but I'm managing lots of relationships between documents, and my data seems pretty structured overall. Does it sound like I should have gone with a RDBMS? How can I tell this in advance before my future projects?In the mean time, I'm still handling relationships within Mongo. What is the best way to do this. For example, my website consists of teams that consist of 5-10 players. Should I store the team id in the player document? Should I store an array of players in the team document? What are the advantages of doing one vs the other? Are there advantages of doing both?Similar questions, but on a different scale. Every game consists of 10 players, and players have connections to many games. How do I handle these relationships? What is the best way to query for a player's complete game log? I have to store a player's game stats in that game document, but should I cache this information in the player document as well?I hope I provided enough context that questions can be answered. Thanks to anyone who has read this and can help me out.

Submitted April 24, 2018 at 01:25AM by kc9kvu

No comments:

Post a Comment