实体教师和学生的共享表?

发布于 2024-10-17 10:21:38 字数 172 浏览 1 评论 0原文

我必须创建一个数据库,我想知道什么是最好的解决方案。

假设我必须存储有关学生和教师的信息。

我应该制作一张包含学生和老师的所有个人信息(姓名、电子邮件、电话密码)的表吗?

有关其他信息,我是否应该将它们作为 ADD_TEACHERS 和 ADD_STUDENTS 保存在单独的表中?

I have to create a database and I want to know what would be the best solution.

Let's say I have to store information about students and teachers.

Should I make one single table containing all the personal information (name,email,phone password) to both students and teachers?

For additional information should I keep them in separate tables as ADD_TEACHERS and ADD_STUDENTS?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

ゃ人海孤独症 2024-10-24 10:21:38

您可能想要为姓名、电子邮件等常用数据创建一个人员表。然后您可以使用此表中的主键列,如果必须有特定于教师的信息(例如 course_instructor ,班主任),然后使用人员的唯一键作为课程信息表中的参考。对学生也做同样的事情。

You may want to create a people table for the common data like name,email etc. You can then use a primary key column in this table, and if there has to be information specific to teacher (like course_instructor, head_teacher of class), then use that unique key from people as reference in your course_information table. Do the same for students too.

丶视觉 2024-10-24 10:21:38

听起来最好的方法是为教师和学生准备一张单独的桌子。您将在教师和学生之间建立所谓的一对多关系:一位教师,许多学生。

但这只涵盖一个学期。当您考虑其他学期时,学生和老师之间存在多对多的关系。

最后,您最好至少拥有三个表:教师、学生和师生关系。

It sounds like your best route is to have a separate table for teachers and students. You'll have what is called a one-to-many relationship between teachers and students: one teacher, many students.

But that only covers one semester. When you consider other semesters, you have a many-to-many relationship between students and teachers.

In the end, you're best off with at least three tables: Teachers, Students, and teacher-to-student relationship.

极致的悲 2024-10-24 10:21:38

您要做的第一件事是映射实体关系(ER)及其属性。然后设计数据库并应用规范化策略。

在提议的场景中,学生和教师是不同的实体。并找出他们的关系

  • 一个学生一个老师
  • 许多学生有一个老师
  • 许多学生有许多老师

然后检查他们的属性示例 - 学生(姓名,班级,出生日期)

First thing you have to do is Map the entity relationships (ER) and its attributes.then design the database and apply the normalization strategies.

In the proposed scenario students and teachers are different entities . and find out thier relationship

  • ONE student ONE TEACHER
  • MANY Students HAVE ONE TEACHER
  • MANY Students HAVE MANY TEACHERs

Then check out their attributes Example - Student(Name,Class,DOB)

情徒 2024-10-24 10:21:38

这取决于您将如何使用这些数据。如果您有很多对“人”感兴趣的用例,无论角色如何,或者如果您有很多人既是老师又是学生,您可能想学习 gen-spec 设计模式,因为它适用于关系表。

查看之前的讨论。

It depends on how you are going to use the data. If you have a lot of use cases where you are interested in "persons", regardless of role, or if you have a lot of persons who are both teachers and students, you may want to learn the gen-spec design pattern, as it applies to relational tables.

See previous discussion.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文