1

I've found in some videos that say a weak entity has a total participation and weak relationship in er diagram. In other videos it isn't. I couldn't find a clear explanation for this. Please can someone explain this to me.

For example, this states that the weak relationship exists when there is no primary key of the parent entity attached on the weak entity. Is it true?

1 Answer 1

2

A weak entity type is one whose primary key contains a relationship to another entity. Total participation in a relationship means that every instance of an entity type must be paired across that relationship to the entity instance at the other end of the relationship. Add in the theoretical requirement that an entity type's primary key must not contain NULLs and you have the solution: a weak entity's key contains a reference to another entity and that reference cannot be NULL i.e. the weak entity has a total participation in that relationship.

In physical terms we can represent the weak entity type's implementation as a table like this:

create table weak_entity
(
  parent_id  not null,
  weak_id    not null,
  other_columns,

  primary key(parent_id, weak_id),

  foreign key(parent_id) references parent(parent_id)
);

Note that parent_id is NOT NULL so weak_entity has total participation in this relationship.

The converse need not be true - the "parent" entity need not have total participation across the same relationship.

In real life some DBMS do allow nullable columns in a key. Then the total participation requirement is relaxed. That's the messy reality of real life, distinct from nice relational theoretical considerations.

Your reference says a weak relationship

exists when the PK of the related entity does not contain at least one of the PK attributes of the parent entity. For example, if the PK of a COURSE entity is CRS_CODE and the PK of the related CLASS entity is CLASS_CODE, the relationship between COURSE and CLASS is weak.

In other words, the foreign key column(s) in the child (that reference the parent's primary key) must not be part of the child's primary key. This contrasts with the definition of a weak entity (above) which says the parent's key must be part of the child's primary key. The implementation would look something like

create table strong_entity
(
  strong_id    not null,
  other_columns,
  parent_id  not null,

  primary key(strong_id),

  foreign key(parent_id) references parent(parent_id)
);

From this I would say a weak entity must have a strong relationship to that parent and a strong entity must have a weak relationship.

Note that a "child" table can have foreign keys referencing many other "parent" tables. Some of those relationships may be part of the child's primary key (and will be strong relationships) and some may not (and are therefore weak relationships).

As an example consider a Q&A site where a user can comment on many posts and a post can have comments from many users. The PK of entity Comment would likely contain the FKs referencing Post's PK and also the FK referencing User's PK. So Comment is a weak entity (its PK contains FKs) and those relationships are strong. Now imagine Comment also has a relationship to a table of IP addresses. That relationship is not part of the PK of Comment so it is a weak relationship.

Although PK columns should be mandatory there is no such theoretical restriction on FK columns. Therefore the columns implementing a weak relationship can be nullable and we cannot say, in general, whether there must be total participation over a weak relationship.

2
  • What about weak relationship? coursehero.com/file/p2gfua0/… This states that the weak relationship exists when there is no primary key of the parent entity attached on the weak entity. Is it true? Feb 12, 2020 at 15:11
  • The wording of your comment is very loose. It depends on what you mean by "attached". If the parent entity is "attached" in some way to the child there is no relationship at all and the discussion is moot. Feb 16, 2020 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.