Weak entity

from Wikipedia, the free encyclopedia

In a relational database , weak entities are entities that cannot be identified by their attributes alone. Therefore, foreign keys must be used to form a primary key together with the rest of the attributes . The foreign key is usually the primary key of the strong entity, which is superordinate to the weak entity or on which the weak entity is dependent. The weak entity therefore cannot exist without the associated strong entity.

There are different forms of representation for entity relationship diagrams . In Chen notation , weak entities are represented by bold or bordered rectangles. A bold line or a bordered line leads from the weak entity to a diamond, which describes the relationship and is connected to the superordinate strong entity. This type of relationship is called an identifying relationship and is indicated in IDEF1X notation by an oval entity rather than a rectangular entity. In the case of identifying relationships, the primary key of the superordinate strong entity is passed on to the weak entity and used there for the composite primary key.

Usually, but not necessarily, primary keys of weak entities do not contain any other attributes apart from the inherited primary key and a sequential number. There are two types of weak entities: associative entities and subtype (subtype) entities . Associative entities are used to resolve many-to-many relationships in relational databases and only contain the foreign keys of the associated entities. Subtype entities use inherited attributes from parent strong entities and are an important part of normalizing databases .

Two types of subtype relationship are possible in IDEF1X :

  • Complete subtype relationship , if all categories are known.
  • Incomplete subtype relationship , if not all categories are known.

An example of a weak entity without a subtype relationship would be "header / detail" displays in various real-world situations, such as orders and invoices, in which the header contains the common information while the details contain specific information about the individual items.

The standard example of full subtype relationships is an entity for parties. The PARTY TYPE discriminator, which can include individuals, partnerships, companies and official elements, requires two sub-type entities: PERSON and ORGANIZATION. Where PERSON contains information about individuals, such as first name, last name and birthday, while ORGANIZATION contains attributes such as the full legal name and organizational hierarchies.

In databases, subtype relationships are represented by the superordinate strong entity becoming a so-called base table. The subordinate entities are derived from it and therefore correspond to weak entities. Referential integrity is guaranteed through cascading updates and cascading deletions.

example

An example of a weak entity in an ER diagram, Chen notation

This example is about a database which stores the orders from customers, each order containing one or more items that are for sale. The database contains a table for customers, who are identified by their unique customer number ( primary key ). Another table contains the articles available for sale, which can be identified by product numbers (primary keys). In addition, the database contains two additional tables for storing orders.

One of these tables stores the orders directly, which can be identified with unique order numbers (primary key). In addition, the associated customer numbers ( foreign keys ) as well as other information such as date, time, place of delivery and payment method are saved.

The other table stores the items ordered, which are identified by means of a key made up of the order number (foreign key) and an item number. Other attributes, such as the product number (foreign key) of the article ordered, the number, the price, discounts and special options are also stored in this table. No, one or more items ordered from this table can belong to an order from the table mentioned above. However, ordered items cannot exist without an associated order. (The case that there are no ordered articles for an order should normally only occur when the order is saved for the first time and no associated ordered articles have yet been entered.)

That table saves weak entities , since an ordered article cannot exist without an associated order. It can be argued that an ordered article contains information even without an associated order, as this means that it is known that an unknown person has ordered a certain article at an unknown time. This information is useful, but is not of great value. For evaluations of developments and trends over times or regions, the information that is available in the order table is necessary.

An order would not exist without the article and the ordering person, so it can be argued that the order is also a weak entity. In this case, the attributes of the articles ordered could also be saved in the order table.

See also

literature

  • Peter Pin-Shan Chen : The entity-relationship model — toward a unified view of data . In: ACM Transactions on Database Systems . 1976, p. 9-36 .
  • Balaban, Mira, and Peretz Shoval: Resolving the “weak status” of weak entity types in entity relationship schemas . In: Conceptual Modeling — ER'99 . 1999, p. 369-383 .
  • Song, Il-Yeol, Mary Evans, and Eun K. Park: A comparative analysis of entity-relationship diagrams . In: Journal of Computer and Software Engineering 3.4 . 1995, p. 427-459 .

Web links