Hybrid deployments with PHP Laravel Mysql + Mongodb

Asked

Viewed 147 times

0

I’m developing a system with PHP Laravel + MongoDB.

The login and password part will be modeled using MySQL and use MongoDB to make a quiz. I was thinking of putting together a Schema in MongoDB of that kind:

var quiz = [{

    user_id: 1, //Auth::id() | O id do user vai vir do Auth do php laravel
    name: "Quiz 1",
    question: [{
        title: 'question1',
        type: 'radio',
        elements: ['radio1', 'radio2', 'radio3', 'radio4'],
        correct: ['radio1'],
        resposta: ['radio3'] //errou
    },{
        title: 'question 2',
        type: 'checkbox',
        elements: ['checkbox1', 'checkbox2', 'checkbox3', 'checkbox4'],
        correct: ['checkbox1', 'checkbox2'],
        resposta: ['checkbox1','checkbox2'] //acertou
    }]
}];

It is commonly, in the projects, to make a hybrid deployment of two banks?

  • I would do everything in Mysql, but nothing prevents such a process. If you don’t have as much knowledge in Mongodb then don’t use ...

  • What is your reason for using Mongodb instead of Mysql?

  • @Gabrielrodrigues I think it’s easier to do everything in one Schema than to create several tables, make the Foreign Keys and later the joins.

1 answer

0

The answer to your final question is: it depends. If you want to do a hybrid implementation, no problem, think carefully about the justifications for doing it (or not doing it). Considerations/questions that occur to me to help decide:

  • Do you already have users in Mysql? You can migrate them to Mongodb if applicable?
  • Want to take advantage of the referential integrity (joins) that Mysql already offers you?
  • Want to take advantage of the schema change flexibility in Mongodb? (Remember the 16MB document size limit)
  • If you use two banks you will need to manage two banks! two backups, two processes, two query optimizations...
  • Your system can grow to many users/base size/traffic that justifies Mongodb’s scalability?
  • Like the @Virgilio Novic comment, do you have experience with using/admin on Mongodb? Who knows wants to use the project precisely to gain experience.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.