Entity-relationship modelling

Posted in Computing, Databases

Entity-relationship modelling provides a conceptual data model which describes how data in a system is grouped, related and linked.

There are 3 key terms in entity-relationship modelling:

  • An entity is an object about which data is to be stored. For example: Customer, Supplier, Employee, Student
  • An attribute is a property or characteristic of an entity. For example: attributes of a student could be name, age, address
  • A relationship is a link between two entities. For example One student studies many subjects and each subject is taught to many students.

Relationships

There are 3 types of relationships between entities:

  • One to one - for example: husband and wife, one husband (should have!) only one wife and vice versa
  • One to many - for example: father and children, one father may have many children but those children only have one father
  • Many to many - for example (as above): student and subject, each student many study many subjects and each subject is taught to many students

E-R diagrams

E-R diagrams represent the relationships between entities in diagrammatic form. Entities are represented as boxes and relationships by lines between them. A 'crows foot' represents a to many relationship. Below are the diagrams of the above 3 examples:

E-R diagram example

The relationships are read both ways, for example one father has many children (left to right) and many children have on father (right to left)

Applying E-R modelling to diagrams

E-R modelling and diagrams can be used to represent relational databases with the entities representing the tables of the database and the relationships the links between them.