Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

handisb's avatar

Does Laravel support different types of database systems?

I need to arrange my data in a way that might need a different structure on top of Laravel. The schema that I am talking about will allow more flexibility in the fields of our models. We want to do this because we want to be able to more simply and robustly arrange our data. And it should make our database faster. Instead of the columns defining the fields to be tracked, the database will define a foreign_id column, a type column and a value column, so that the type column maps the name of a field that the value corresponds to, and that maps onto the foreign id. So we want to set up this new structure so it's a lot more simple and easier for us to manage the enormous amount of data that we're going to be handling. So we have a couple of questions.

  1. Does this already exist within the Laravel framework? We know that Laravel is pretty robust and we figure that there might be something like it already.
  2. If it does not exist in Laravel, then how would we implement this and connect it within Laravel? We assume that we would need a plugin. What plugin would it be?
0 likes
5 replies
jlrdw's avatar

I would suggest browsing over the documentation, because yes it does exist.

marosmjartan's avatar

As far as I know, Laravel support only SQL types of database.

I recommend looking at the polymorphic relations, that might be helpful. Or if you want really big flexibility and some sort of replacement of the NoSQL, you should try JSON columns. Laravel can also perform querying on JSON columns -> https://laravel.com/docs/8.x/queries#json-where-clauses

But be careful about using JSON columns -> you will lose some performance. I recommend watching this before https://www.youtube.com/watch?v=9uhXI4nDpOQ

Tray2's avatar

Yes it's supported and I have suggested that approach in many of my answers regarding database solutions when for example products have wastly different properties.

While json columns as @marosmjartan suggests might sound like a good solution for this, it's not. It will make every query slower and more complex.

As for using something like NoSQL might be an option but in your case it sounds like you need a regular relational database.

In short go with Polymorhic relations.

Please or to participate in this conversation.