问题描述
尝试设置实体关系,但很难找出一个关系,我需要:
我有一个单一的实体,人。人有两个关系,super_friend和sub-friend。每个实体可以有很多朋友(一个Person Entity),所以sub_friend是多对多的关系。我不知道超级朋友是什么;一对多或多对一的关系。
例如:Bill是Fred和Ted的朋友。爱丽丝也是弗雷德的朋友。
这是不是意味着弗雷德的超级朋友需要多对多?
:
实体人Bill的sub_friend指向Fred和Ted。
实体人Alice的sub_friend指向Fred。 / p>
所以Fred的超级朋友对Entity Bill和Entity Alice有什么关系?如果我拉起实体弗雷德,它只会指向比尔还是爱丽丝?
我认为只是回答了我的问题。我需要实体Fred指出比尔和爱丽丝,所以对多。我想让每个实体都是独一无二的。
如果我不在乎Fred的超级朋友是什么?
编辑2:
b
由于confustion让我扩大我的需要:我需要排序横向实体。
所以说我是比尔,我需要看看谁的所有Bill的sub_friends (Fred和Ted)。我选择Fred。然后我需要找到所有的弗雷德的子朋友并选择一个等等。我需要能够做这n次。
只有朋友关系的解决方案不会让我保持朋友分离。说弗雷德知道约翰和斯蒂丝。当我查询Fred,我不知道John是否超过(super_friend和不在乎)或者如果John是一个sub_friend(需要在表视图中进行选择)。
只需看看这个图表:
像你看到的Bill有很多sub_friend的,Fred是许多实体的sub_friend。 >
这是一个多对多的关系。
EDIT
我认为这很明显,但sub_friend是super_friend的逆向关系,因为如果Bill有Fred作为sub_friend,那么fred有Bill作为super_friend。
Trying to setup a Entity relationship but having difficulty figuring out a relationship i need:
I have a single Entity, Person. Person has two relationships, super_friend and sub-friend. Each Entity can have many friends (a Person Entity), so sub_friend is to-many relationship. I am not sure what super_friend is; a to-one or a to-many relationship.
Example: Bill is friends with Fred and Ted. Alice is also friends with Fred.
does this mean Fred's super_friend needs to be to-many?
EDIT:
Entity Person Bill's sub_friend points to Fred and Ted.
Entity Person Alice's sub_friend points to Fred.
so what relationship does Fred's super_friend have to Entity Bill and Entity Alice? If I pull up Entity Fred, will it only point to Bill or Alice?
I think that just answered my question. I would need Entity Fred to point to both Bill and Alice, so to-many. I want each Entity to be Unique.
What if i don't care about who Fred's super_friends are? i would only ever transverse "down" through sub_friends, never "back up" through super_friend/s.
EDIT 2:
Due to confustion let me expand my need: i need to sortive transverse the Entities.
So say I am Bill, i need to see who all Bill's sub_friends (Fred and Ted). I select Fred. I then need to find all of Fred's sub_friends and select one, etc. I need to be able to do this n times.
A solution with just a friend relationship would not allow me to keep the friends separate. Say Fred knows John and Stacy. When i query Fred, i won't know if John is above (super_friend and won't care about) or if John is a sub_friend (need to present in a table view for selection).
Just look at this diagram:
Like you see Bill has many sub_friend's, and Fred is sub_friend of many entities.
So it's a to-many relationship.
EDIT
I thought it was pretty obvious, but sub_friend is the reverse relationship of super_friend, because if Bill has Fred as sub_friend, then fred has Bill as super_friend.
这篇关于核心数据和反射性实体关系(一对一或一对多)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!