英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论