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

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

问题描述

例如:我在我的数据库中的两个表名为 CLASSA CLASSB ,和一个表中调用的 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。即一个学生链接到他的朋友,谁是学生也是如此。

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.

所以模拟到上面的技术,我有:学生 student_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 or Owner and Child is the generally accepted solutions.

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

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