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

Coola's avatar
Level 1

Laravel use MySQL or Firebase/NoSQL?

I am setting up a content management system in Laravel using Google Cloud Platform. This CMS will have quite a few polymorphic many-to-many relationships (at least 10) and for that reason I am considering whether I can use Firebase or other NoSQL databases with Laravel.

I know that there is a laravel-firebase package by Kreait which should allow me to use the firebase as database. My question is therefore

  1. Are there any drawbacks to using firebase with laravel, which I should be aware of?
  2. Can I possibly use a hybrid model where some data is stored in the SQL database while other is stored in firebase
  3. Or should I just stick to MySQL and create the several polymorphic many-to-many relationships?
0 likes
9 replies
drehimself's avatar

I think you should use what you know best.

With that being said, I'm going to recommend sticking with a MySQL database since the majority of Laravel devs use relational databases. If you get stuck on something, you're more likely to find help with a relational database as opposed to a NoSQL database (within the context of Laravel/Eloquent).

Coola's avatar
Level 1

Such comparison sites are what confuses me, and therefore I would like to hear from anyone who actually tried both databases and what their experience was.

martinbean's avatar

@coola It’s impossible to say without knowing what the entities in your CMS are and how they relate to one another.

If you’re able to give us more details, then we’ll be able to give more advice.

Coola's avatar
Level 1

@martinbean thanks for your response. The CMS is for a laboratory so there are tables for diseases, cells, proteins, cell locations, tissues which belong to multiple types of experiments. So these tables are related to the experiments in a many-to-many relationship but the experiments themselves are of several types and hence polymorphic. Experimental data will run into 100s of thousands of rows easily and I think SQL would be great for that, but what worries me are the polymorphic relationships, e.g. there may be use cases where the scientists may need to check disease or cell data across for a specific data point on the fly. So I am not even sure if Laravel can handle manythrough queries through a many-to-many polymorphic table.

Tray2's avatar

This doesn't reslly have anything to do with Laravel, it's more of a database question. MySQL can with the proper SQL, idexes and good database design handle millions of records without any problem.

Since you are talking about relations I'd say stick with a relational database.

If MySQL can't perform well enough you can always use Postgres or an Oracle database.

Remeber that no matter which RDBMS you choose you need to have a good database model and the correct indexes. It's also very important to only get the data you need from the database to minimize the memory usage.

I can highly recommend this course by Jonathan Reinink

https://eloquent-course.reinink.ca/

Coola's avatar
Level 1

@tray2 thanks for your response. You are right it is more of a database question, but laravel and the database do go hand-in-hand. I am not just worried about performance but also maintainability and ability to expand to new data types, which is where I feel the NoSQL database would offer some advantages due to its flexibility. Thanks for the link, I will definitely check it out, I also checked out https://serversforhackers.com/laravel-perf which is a Laravel Performance course for free, so not sure how much of an overlap there is.

martinbean's avatar

@coola I’d say if you have well-defined data, then stick with a relational database. A schema can always be updated in the future with migrations to add/update columns as you uncover requirements. It’s better than just picking a NoSQL solution because you can chuck whatever in it; that’s not a “benefit” in my eyes. Especially when dealing with something in an environment such as a laboratory.

Coola's avatar
Level 1

Thanks @martinbean. I think I will go with MySQL for the time being but maybe try Firestore in an independent project just to see if it works. I might update here on my findings if it helps others.

1 like

Please or to participate in this conversation.