DEV Community

Justin Ho
Justin Ho

Posted on • Updated on

Letting the Framework Dictate My Project

(still backlogged at day 6 at the time of publishing)

Day 4 of 100DaysOfCode

Despite writing an (not so humble) awesome article detailing my database designing skills, I have had to change up my database structure to better fit HypeTracker into the Laravel ecosystem.

The main reasons are:

  1. Many implicit functions work with surrogate keys instead of natural keys for the primary key constraint (basically using an integer id instead of a human readable string)
  2. Eloquent ORM does not support composite primary keys!

I actually already noted the second point in my day 2 post but the combination of these two problems made me unable to retrieve items through the hasMany relationship.

So I just gave up and added id fields as primary keys for all my tables.

Refactoring Migrations to Add ID Primary Keys

Thankfully Laravel migrations made the process of altering table fields using PHP code nice and easy but I am still not happy about wasting that time.

The takeaway? Frameworks have hard rules that are basically "my way or the highway".

Follow my coding adventure on Twitter @justinhodev!

Top comments (0)