Eloquent: is an ORM too restrictive?
Because of this series I'm diving deep into databases. And the last days I'm asking myself the question is the RM in ORM not holding us back in the current database landscape. What is object relational mapping? There are two parts that are the base for the mapping. The first is an object in a programming language that matches an database item, for example in a relational databases that is a table. And the second are the relations between the database items. A relation where two tables have each others ids is called a one to one relationship. By setting up the objects and their relations, the ORM knows how to get and manipulate the stored information in the database. Why is it restrictive? ORM solutions, like Eloquent and Doctrine, are targeting relational databases like Mysql and Postgresql. As I see it graph databases are another great case to create an ORM. But there are other database types, like document and key-value, where the relational part of an ORM is not needed. How to make Eloquent less restrictive For all database types an Entity object can be used, because that is an object that has to be identifiable. For databases that have relations between entities, I would move those to the Builder class, instead of in the model currently. I think the with methods could do the trick with a bit a of modification. And adding a to method for nested inserts. Conclusion The idea at the start of the series was to update Eloquent to use the current PHP features. Thinking about other database solutions it turned into a much bigger task. I have rewritten the section above at least 8 times, because I was rubberducking ideas. Sticking with an ORM solution will be good enough for most cases. And people that don't want to use the ORM will be aware of the consequences.

Because of this series I'm diving deep into databases. And the last days I'm asking myself the question is the RM in ORM not holding us back in the current database landscape.
What is object relational mapping?
There are two parts that are the base for the mapping. The first is an object in a programming language that matches an database item, for example in a relational databases that is a table.
And the second are the relations between the database items. A relation where two tables have each others ids is called a one to one relationship.
By setting up the objects and their relations, the ORM knows how to get and manipulate the stored information in the database.
Why is it restrictive?
ORM solutions, like Eloquent and Doctrine, are targeting relational databases like Mysql and Postgresql.
As I see it graph databases are another great case to create an ORM.
But there are other database types, like document and key-value, where the relational part of an ORM is not needed.
How to make Eloquent less restrictive
For all database types an Entity object can be used, because that is an object that has to be identifiable.
For databases that have relations between entities, I would move those to the Builder class, instead of in the model currently. I think the with methods could do the trick with a bit a of modification. And adding a to
method for nested inserts.
Conclusion
The idea at the start of the series was to update Eloquent to use the current PHP features.
Thinking about other database solutions it turned into a much bigger task.
I have rewritten the section above at least 8 times, because I was rubberducking ideas.
Sticking with an ORM solution will be good enough for most cases. And people that don't want to use the ORM will be aware of the consequences.