核心数据和反射性实体关系(一对一或一对多)

编程入门 行业动态 更新时间:2024-10-24 07:22:51
本文介绍了核心数据和反射性实体关系(一对一或一对多)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

尝试设置实体关系,但很难找出一个关系,我需要:

我有一个单一的实体,人。人有两个关系,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.

更多推荐

核心数据和反射性实体关系(一对一或一对多)

本文发布于:2023-11-14 13:51:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587391.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:反射   实体   核心   关系   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!