替代“主"和“奴隶"在实体关系中? [英] Alternative to "master" and "slave" in entity relationship?

查看:19
本文介绍了替代“主"和“奴隶"在实体关系中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例:我的数据库中有两个表,名为classAclassB,还有一个表名为classA_classB.最后一个只是定义了两个带有外键的 int 字段来链接 classA 和 classB.所以一个classA可以有多个classB,并且多个classA可以链接到同一个classB.简单的东西,到目前为止.

Example: I have two tables in my database called classA and classB, and one table called classA_classB. The last one just defined two int fields with foreign keys to link between classA and classB. So one classA can have many classB, and many classA can link with the same classB. Simple stuff, so far.

问题是,在我的特殊情况下,我有一个想要链接到另一个 classA 的 classA.IE.学生链接到他的朋友,他们也是学生.

The problem is, in my special case, that I have a classA which wants to link to another classA. I.e. a Student links to his friends, who are Students as well.

与上述技术类似,我有:studentstudent_student.student_student 有两个字段:student_id、student_id.问题:不能有两个同名的字段!

So analogue to the technique above, I have: student and student_student. student_student has two fields: student_id, student_id. Problem: Can't have two fields with same name!

所以我必须这样称呼它们:master_student_id、slave_student_id.

So I must call them like: master_student_id, slave_student_id.

但我不喜欢主人"和奴隶"这两个词,因为它们提醒我们过去的一段糟糕时光.这听起来可能很愚蠢,但我认为保留这些是不正确的,至少从道德角度来看是这样.我知道这只是现代计算机科学的一部分,...但是....

But I don't like the terms "Master" and "Slave", because these are reminders to a bad time in our pasts. It may sound silly but I think it's not correct to keep these, at least from a moral perspective. I know it's just a part of modern computer science,... but....

我还能怎么称呼他们?

也许是父母和孩子?另外我不确定是否真的有一个实体首席"而另一个是员工"......学生和学生没有等级.但是,再一次,让我们想象一下我们有两个班级老师"和学生".那将是一个清晰的层次结构.但是,我需要一个中立的解决方案,因为我的框架以相同的方式处理这些 1:n 关系.

parent and child maybe? Also i'm not sure if there's really one entity "the chief" while the other is "the employee"... Student and Student are not hierarchical. But then, again, lets imagine we had two classes "Teacher" and "Student". That would be a clear hierarchy. However, I need a neutral solution because my framework threads these 1:n relationships allways the same way.

推荐答案

Parent and Child 或 Owner and Child 是普遍接受的解决方案.

Parent and Child or Owner and Child is the generally accepted solutions.

这篇关于替代“主"和“奴隶"在实体关系中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆