database 强和弱实体类型的示例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4741967/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 08:01:01  来源:igfitidea点击:

Example of a strong and weak entity types

databaseweak-entity

提问by learner123

I've tried to look on Google about a decent explanation of weakand strong entity type, but I haven't fully understood them.

我试图在谷歌上寻找关于强实体类型的体面解释,但我还没有完全理解它们。

Could someone give me an example of a strong and weak entity type?

有人能给我一个强弱实体类型的例子吗?

回答by Paul

A weak entity is one that can only exist when owned by another one. For example: a ROOMcan only exist in a BUILDING. On the other hand, a TIREmight be considered as a strong entity because it also can exist without being attached to a CAR.

弱实体是指只有在被另一个实体拥有时才能存在的实体。例如:一个ROOM只能存在于一个BUILDING 中。另一方面,一个TIRE可能被认为是一个强大的实体,因为它也可以在不附加到CAR 的情况下存在。

回答by Faheem

Just to play with it, question is strong entity type and answer is weak. Question is always there, but an answer requires a question to exist.

只是为了玩它,问题是强实体类型,答案是弱。问题总是存在,但答案需要问题存在。

Example: Don't ask 'Why?' if Your Dad's a Chemistry Professor

示例:不要问“为什么?” 如果你爸爸是化学教授

回答by utkarsh_shah

A weak entityis the entity which can't be fully identified by its own attributes and takes the foreign keyas an attribute (generally it takes the primary key of the entity it is related to) in conjunction.

弱实体是不能由自己的属性完全识别并采取实体外键作为一个属性(通常花费的实体的主键它关系到)结合。

Examples

例子

The existence of rooms is entirely dependent on the existence of a hotel. So room can be seen as the weak entityof the hotel.
Another example is the
bank account of a particular bank has no existence if the bank doesn't exist anymore.

房间的存在完全取决于酒店的存在。所以房间可以看作是酒店的弱点
另一个例子是,
如果银行不再存在,则特定银行的银行账户也不存在。

回答by Carol

A company insurance policy insures an employee and any dependents, the DEPENDENT cannot exist without the EMPLOYEE; that is, a person cannot get insurance coverage as a dependent unless the person is a dependent of an employee.DEPENDENT is the weak entity in the relationship "EMPLOYEE has DEPENDENT"

公司保险单为雇员和任何家属提供保险,没有雇员就不能存在家属;也就是说,一个人不能作为受抚养人获得保险,除非该人是雇员的受抚养人。DEPENDENT 是“EMPLOYEE has DEPENDENT”关系中的弱实体

回答by Metin Zontul

Strong entity

强大的实体

It can exist without any other entity.

它可以在没有任何其他实体的情况下存在。

Example

例子

Customer(customerid, name, surname)

Weak entity

弱实体

It depends on a dominant entity, and it cannot exist without a strong entity.

它依赖于一个主导实体,没有一个强大的实体它就不可能存在。

Example

例子

Adress(addressid, adressName, customerid)

回答by Xufeng Wang

Weak entity exists to solve the multi-valued attributes problem.

弱实体的存在是为了解决多值属性问题。

There are two types of multi-valued attributes. One is the simply many values for an objects such as a "hobby" as an attribute for a student. The student can have many different hobbies. If we leave the hobbies in the student entity set, "hobby" would not be unique any more. We create a separate entity set as hobby. Then we link the hobby and the student as we need. The hobby entity set is now an associative entity set. As to whether it is weak or not, we need to check whether each entity has enough unique identifiers to identify it. In many opinion, a hobby name can be enough to identify it.

有两种类型的多值属性。一个是对象的简单许多值,例如作为学生属性的“爱好”。学生可以有许多不同的爱好。如果我们将爱好留在学生实体集中,“爱好”将不再是唯一的。我们创建了一个单独的实体集作为爱好。然后我们根据需要将爱好和学生联系起来。爱好实体集现在是关联实体集。至于它是否弱,我们需要检查每个实体是否有足够的唯一标识符来识别它。在许多人看来,一个爱好名称就足以识别它。

The other type of multi-valued attribute problem does need a weak entity to fix it. Let's say an item entity set in a grocery inventory system. Is the item a category item or the actually item? It is an important question, because a customer can buy the same item at one time and at a certain amount, but he can also buy the same item at a different time with a different amount. Can you see it the same item but of different objects. The item now is a multi-valued attribute. We solve it by first separate the category item with the actual item. The two are now different entity sets. Category item has descriptive attributes of the item, just like the item you usually think of. Actual item can not have descriptive attributes any more because we can not have redundant problem. Actual item can only have date time and amount of the item. You can link them as you need. Now, let's talk about whether one is a weak entity of the other. The descriptive attributes are more than enough to identify each entity in the category item entity set. The actual item only has date time and amount. Even if we pull out all the attributes in a record, we still cannot identify the entity. Think about it is just time and amount. The actual item entity set is a weak entity set. We identify each entity in the set with the help of duplicate prime key from the category item entity set.

另一种类型的多值属性问题确实需要一个弱实体来解决它。假设在杂货库存系统中设置了一个项目实体。该项目是类别项目还是实际项目?这是一个重要的问题,因为客户可以一次以一定的金额购买相同的商品,但他也可以在不同的时间以不同的金额购买相同的商品。你能看到它是同一个项目但不同的对象吗?该项目现在是一个多值属性。我们通过首先将类别项目与实际项目分开来解决它。两者现在是不同的实体集。Category 商品具有商品的描述性属性,就像您通常想到的商品一样。实际项目不能再有描述性属性,因为我们不能有冗余问题。实际项目只能有项目的日期时间和数量。您可以根据需要链接它们。现在,让我们谈谈一个是否是另一个的弱实体。描述性属性足以识别类别项目实体集中的每个实体。实际项目只有日期时间和金额。即使我们提取出记录中的所有属性,我们仍然无法识别实体。想想这只是时间和数量。实际的项目实体集是一个弱实体集。我们在类别项实体集中的重复主键的帮助下识别集合中的每个实体。我们仍然无法识别实体。想想这只是时间和数量。实际的项目实体集是一个弱实体集。我们在类别项实体集中的重复主键的帮助下识别集合中的每个实体。我们仍然无法识别实体。想想这只是时间和数量。实际的项目实体集是一个弱实体集。我们在类别项实体集中的重复主键的帮助下识别集合中的每个实体。

回答by Doren

./Database/DataModels/RelationalDataModel/WeakEntity

./Database/DataModels/RelationalDataModel/WeakEntity

It probably can be written in two factors:

大概可以写成两个因素:

  • DEPENDENCE:Depends on the existence of an identifying entity set (total, one-to-many relationship).
  • IDENTIFICATION:Does not have a primary key. It has a partial key (or discriminator). It needs to use the primary key of another table for identification.
  • DEPENDENCE:依赖于识别实体集的存在(总的,一对多的关系)。
  • 标识:没有主键。它有一个部分键(或鉴别器)。它需要使用另一个表的主键进行标识。

If we would think of a database holding questions and answers, then the questions would be the strong entity and the answers would be the weak entity. So, Question (id, text)and Answer (number, question_id, text)would be our tables. But why is the Answer's table a weak entity?

如果我们考虑一个包含问题和答案的数据库,那么问题将是强实体,答案将是弱实体。因此,Question (id, text)Answer (number, question_id, text)将是我们的表格。但是为什么答案表是一个弱实体呢?

  • Dependence to the question table.Every answer is connected to one question (assumption) and so it cannot be on its own. That is why we have people who ask one question and answer it themselves so that they can help other people and get some extra likings.

  • Identification from the primary key of the question. One would not be able to identify an answer (assuming that its id is a number identifier) because a question might be answered by answers whose identifier might exist in other questions too. Primary key of the answer table: (number, question_id).

  • 对问题表的依赖。每个答案都与一个问题(假设)相关,因此它不能独立存在。这就是为什么我们会有人提出一个问题并自己回答,这样他们就可以帮助其他人并获得一些额外的喜好。

  • 从问题的主键识别。人们将无法识别答案(假设它的 id 是一个数字标识符),因为一个问题可能会被答案回答,其标识符也可能存在于其他问题中。答案表的主键:(number, question_id)。

回答by arya

Weak entitiesare also called dependent entities, since it's existence depends on other entities. Such entities are represented by a double outline rectangle in the E-R diagram.

弱实体也称为依赖实体,因为它的存在依赖于其他实体。此类实体在 ER 图中由双轮廓矩形表示。

Strong entitiesare also called independent entities.

强实体也称为独立实体。

回答by gimmegimme

After browsing search engines for a few hours I came across a site with a great ERD example here: http://www.exploredatabase.com/2016/07/description-about-weak-entity-sets-in-DBMS.html

在浏览了几个小时的搜索引擎后,我发现了一个有一个很好的 ERD 示例的网站:http: //www.exploredatabase.com/2016/07/description-about-weak-entity-sets-in-DBMS.html

I've recreated the ERD. Unfortunately they did not specify the primary key of the weak entity.

我重新创建了 ERD。不幸的是,他们没有指定弱实体的主键。

enter image description here

在此处输入图片说明

If the building could only have one and only one apartment, then it seems the partial discriminator room number would not be created (i.e. discarded).

如果建筑物只能有一间且只有一间公寓,那么似乎不会创建(即丢弃)部分鉴别器房间号。

回答by Wasiq Mahmood WM

Weak Entity Type: An entity whose instances cannot exits without being linked with instances of some other entity is called weak entity type. It cannot exist independently. For example: Our PC is depend on us it will not open or close with its own.

弱实体类型:一个实体的实例不能在没有与其他实体的实例链接的情况下退出,称为弱实体类型。它不能独立存在。例如:我们的 PC 依赖于我们,它不会自行打开或关闭。

Strong Entity Type: An entity whose linked to the instances of any other entity type is called strong entity type. It can exit independently. For example: A person can do every thing can go everywhere and use ever thing

强实体类型:链接到任何其他实体类型的实例的实体称为强实体类型。它可以独立退出。例如:一个人可以做每件事可以去任何地方使用任何东西