在 Laravel 中将用户存储在一个表中还是多个表中。

huangapple go评论51阅读模式
英文:

store users in one table or multiple table Laravel

问题

我们正在使用Laravel创建一个电子学习网站,拥有多个用户(学生、讲师、管理员)。我们应该将它们存储在一个表(users)中,还是每个用户都有自己的表。

我想知道是否有一个惯例。

英文:

we are creating an e-learning website with Laravel, and we have multiple users (student, instructor, admin) should we store them in one table (users) or each user with own table.

I want to know if there is a convention

答案1

得分: 0

在这方面没有铁定的规则,完全取决于您。但根据我在大多数Laravel项目中看到的以及我在自己的项目中所做的,为了更容易阅读和排除故障,您可以使用单一的“users”表,并创建一个“profile”或“profile_type”列来确定它们附加到哪一个。

英文:

There is no set in stone rule, it is totally up to you. But from what I see in most Laravel projects, and what I do in my projects as well, to make it easier to read/troubleshoot you use a single "users" table and make a "profile" or "profile_type" column to determine which one are they attached to.

huangapple
  • 本文由 发表于 2023年2月19日 19:17:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75499749.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定