Entity Life History (ELH)
Introduction to Entity Life History diagrams
Entity life histories are used to describe what happens to an entity over time. They describe the events that can happen to an entity. For example, if you had an entity PUPIL in which you stored all the details of pupils at a school, the kinds of the things that could happen to the table of records include:
- a record could be added. (when a pupil joins the school)
- a record could be deleted. (when a pupil leaves the school)
- a record could be amended (when a pupil changes address, for example).
Why use ELH diagrams at all?
Entity life histories are important because they help you design into the database those forms and actions that are needed to service each event. For example, to cater for when a new pupil record is added, you will need to design an input form. If you have to output a report listing all pupils then you will need a query to do it and so on. ELH diagrams help a designer because they provide a checklist of functions that must be catered for. A function often overlooked by pupils when doing coursework is that of deleting data from a database. Many build systems that forever allow data to be entered but never removed! Had an ELH been drawn for each entity, they would have identified those entities where data 'dies'. They could then have designed functions for the user so that they could carry out data removal tasks at appropriate times.
An entity life history diagram should be prepared for each entity in a system. The diagrams used are based on the Jackson Structured Programming diagrams and generally need to show three main stages in the life of the entity:
- The Birth
- The Life
- The Death
An example of producing an Entity Life History diagram
Consider a library. If you had an entity 'BOOK', you might start with the following diagram:
You might decide that the events that could happen to that entity are:
- it is ordered
- it arrives
- it is entered into the catalogue system ready for borrowing
- it gets borrowed
- it gets returned
- it gets removed from the library, either sold or thrown away.
We will change the names of Birth, Life and Death to something more appropriate to libraries and books. A first attempt at the ELH diagram might be:
ELH diagrams use JSP notation. If you remember the work done previously on JSP diagrams, you will know that there are three important constructions that need to be shown on the diagram. These are sequence, selection and iteration.
- Sequence. The diagram needs to be read from left to right. Time passes from left to right so you can see each event happening over time.
- Selection. When a book is going to be removed from the library, one of two things can happen to it. It can be sold OR scrapped. Selection (this event OR that event) is shown by putting a small zero in the top right hand corner of the possibilities.
- Iteration. A book can be lent out and returned many times. This is iteration. It is shown by adding an extra box with a star in it and a comment that signals how the iteration ends.
Your diagram should now look like this:
Well, nearly! A common mistake when representing iteration is to miss something out. Look at the diagram above and see if you can spot what was missed out.