gpt4 book ai didi

php - Laravel 仅使用 MongoDB 还是使用 MongoDB + MySQL 进行身份验证?

转载 作者:行者123 更新时间:2023-11-29 05:07:21 25 4
gpt4 key购买 nike

我正在构建一个 Laravel 应用程序。我的数据需要我有一个 mongoDB 数据库,所以我正在使用 Laravel + MongoDB 构建应用程序。到目前为止运行良好,但在考虑用户身份验证时,我不确定 Mongo 是最佳选择,因此我在使用 Mongo 或拥有一个额外的 Mysql 数据库仅用于用户身份验证之间存在分歧。

仅使用 Mongo 使应用程序更简单(只有一个数据库适配器),但将用户保存为 json 文档似乎有点糟糕的设计(抱歉,我来自 SQL 背景)。不仅如此,而且随着我的数据的增加,似乎对用户的查询调用需要越来越长的时间才能返回。

另一方面,MySQL 会向应用程序添加一个额外的数据库适配器,额外的服务器内存负载以保持 mysql 运行,以及一个从长远来看可能会失败或崩溃的端点,但我觉得它会更快地检索用户并对其进行身份验证。

将我的用户数据存储在 MongoDB 而不是 Mysql 中有什么大的缺点,或者使用 MySQL 而不是 Mongo 来存储用户有什么好处?

最佳答案

I'm building a Laravel app. My data requires me to have a mongoDB database, so I'm building the app with Laravel + MongoDB. Works well so far, but when condidering user authentication, I'm not sure Mongo is the best option, so I'm divided between using Mongo or having an extra Mysql database just for user auth.

加油吧!
不要害怕使用 MongoDB 作为身份验证存储。没有令人信服的理由仅使用 MySQL 进行身份验证,因为其他一切都有 MongoDB。

...but it seems that saving users as json documents a bit of bad design (sorry, I come from a SQL background). Not only that, but as my data increases, seems that query calls for users would take longer and longer to return.

那只是一种误解!
最多,查询 MongoDB 太快了。你现在不应该为此担心。

On the other hand, MySQL would add an extra db adapter to the app, extra server memory load to keep mysql running, and one more endpoint that can fail or crash on the long run...

很公平!
根据我的经验,维护 MySQL(在当前上下文中)仅用于身份验证是一件痛苦的事情:
2 台服务器、2 次备份、2 次恢复、2 次部署、额外的配置和更多令人头疼的事情……

即使 Moloquent(我想应用程序有 jenssegers/laravel-mongodb 包,充其量...)支持混合关系只有一个数据库要容易得多。

结语

好吧,在决定使用 MongoDB 进行身份验证之前,您应该修改用户类文件,切换/引用适当的 namespace (mongo)。有点工作,但值得!
过去,我为 MongoDB 从 MySQL 导入了所有用户,对此我非常满意。

关于php - Laravel 仅使用 MongoDB 还是使用 MongoDB + MySQL 进行身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45491085/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com