The relational model
In last week's material we briefly mentioned the four essential elements of a data model. It is very important to know what they are and to understand their role, so here is a reminder:
|Entities||The important things in the real world that need to be modelled. Groups of the same type of objects are called entity types or entity sets. Entity sets are represented in a database by tables, and each row in a table represents one entity of that type.
e.g. People, places, objects, events, etc.
|Attributes||Individual items of data associated with an entity. Entities of the same type have the same attributes, but the values of those attributes may differ from one entity to another. That is the same as saying that all records in a table share a particular column, but the values in that column may be different for each row.
e.g. Name, national insurance number, weight, date of manufacture
|Relationships||Ways in which entities are connected
e.g. A is part of B, A lives in B, A produces B, A takes place in B, etc.
|Constraints||Rules which place limits on the data that is allowed
e.g. Every A must have a B, Only future dates are allowed, etc.
When describing a model of a real-world situation, it is useful to show it in a diagram. We can use rectangles to represent entities, and connecting lines to represent relationships between entities:
This type of diagram is called an entity-relationship diagram (ER diagram or ERD) for obvious reasons. This is a very simple example, and we will go on to explore how the essential information about the details of the database structure can be included.
Being able to read and draw accurate ER diagrams that correctly reflect the database structure is essential. This is one of the key skills in this module, and you will need to demonstrate your skills in this area in the coursework and the exam.