Planning out the relationships between the Objects for my Final Project

Arnie Serrano
3 min readOct 22, 2020

I made it to Mod 5, which honestly is a bit shocking to me. Shocking because I’ve always just sort of focused on what I was doing in the moment I didn’t really take time to look around to see where I was and what I knew while in the previous modules. So to be here thinking and programming my final project that’ll use all that I’ve learned, from backend to frontend. is a bit of a struggle to be honest. But, hopefully I can scrounge up enough material I’ve learned to put something together.

The only real idea I could come up with is a Magic the Gathering deck builder and recommendation website. I had recently started up playing again and at times I searched online for ideas of how to implement cards. A lot of sites I found on Google, at the time, were mostly forum posts that, while useful, didn’t really feel intuitive. After seeing the posts, I would have to look up the cards recommended by other people which is a little unintuitive. I thought it would be far easier to just be able to see the cards recommended as well as the recommended posts by the users.

When I pitched this idea trying to get it approved, I had help from my coach in mapping out the relationships between the models that I’ll need. At first, I had 3 models: User, Deck, and Cards, as well as a Post model. But then I was told that the relationships I had made between the models wouldn’t work.

Outlining the Models

At first I had a simple User has_many: Decks, has_many: Cards through Deck, a Deck has_many: Cards, belongs_to: User, and Cards has_many: decks, has_many: Users through Decks. With this type of relationship, I was told I wouldn’t be able to use the same card for another users deck. Therefore I would need a join table for the deck and card models, which would be labeled DeckCard that holds the deck id’s and the card id’s.

The finished relational map

That just left the Post model to be created, but in order to have an MVP within a week, it’d have to be a stretch goal. Should I have enough time to implement it though, the Post model would serve as the join table between User and Deck, since every post will belong to a user that will never be used by a different user and will forever be associated to the specific deck. In other words, no other user will be using the same post of another user the same way a user would use the same card as another user. Therefore, no join table is needed for User and Post.

As of now, I have a basic flow of the front end going, which will be the subject of another blog post. But as of now these models need to be created and set up so that the cards accessed from the Magic the Gathering API can be saved into a deck.

--

--