top of page

Entities and Relationships

Tutoring Databases > Entities and Relationships

Relationships need to exist between entities and between tables for a database to be useful, otherwise it would just be a collection of tables.

Cardinality of relationships

A relationship between one entity and another entity can be:

  • Many to many - M:N e.g. Many cars can have many colours.

  • One to many - 1:M e.g. One order can have many items on that order.

  • One to one - 1:1 e.g. One person can have one unique ID number and only one ID number can be assigned to one person.

  • This is the cardinality of the relationship.

Entities and entity types

Entities are the "things" in a table. Each entity should be a "thing" of an entity type

Examples of entity types are:

  • People.

  • Employing organisations.

  • Companies.

Strong and weak relationships

A relationship from entity type A to entity type B, mediated by having A’s primary key (PK) as a foreign key in B, is strong when B’s PK contains A’s PK. 

A relationship is weak if it is not strong! Most relationships are weak.

 

A PK is a Primary Key. More on this in Keys.

Strong and weak entity types

An entity type E is weak when it is existence dependent on another entity type F. Therefore E -> F is MANDATORY.

Any entity type that gets only weak relationships is strong.

Usually entity types are strong.

bottom of page