Presentation is loading. Please wait.

Presentation is loading. Please wait.

Entity-Relationship (E-R) Diagrams

Similar presentations


Presentation on theme: "Entity-Relationship (E-R) Diagrams"— Presentation transcript:

1 Entity-Relationship (E-R) Diagrams
Databases Entity-Relationship (E-R) Diagrams

2 Learning Objectives Draw entity-relationship (E-R) diagrams to represent data models diagrammatically. Design simple relational databases to the third normal form (3NF).

3 Data Modelling terms Entity: Attribute Relationship
An object, person, event or ‘thing’ a data model requires data to be recorded about. Attribute A property / characteristic of an entity. A field (column) in a database table. Relationship An association or link between two entities.

4 Entity-Relationship (E-R) Diagrams (Entity or data model)
A diagrammatic means of showing a data model / database. Illustrates the relationships between entities in the database and attributes of each entity.

5 Example Data Model Every student in a school belongs to a form.
Every student achieves many exam grades. Every form has a form tutor and all the form tutors are members of the teaching body.

6 Entities & their relationships in this example data model
STUDENT Many students can be in a FORM. Many STUDENTs can achieve many grades. GRADE Many GRADEs can be achieved by many STUDENTs. FORM One form for many students (students cannot be members of more than one form). A FORM can only have one TUTOR. TUTOR A TUTOR can only be in one FORM. Many TUTORS can be in the teaching body. TEACHING BODY There is only one TEACHING BODY(teaching body) for all TUTORs. N.B. All entities are written in the singular.

7 Symbols for relationships between entities
one-to-one represented by one-to-many represented by many-to-one represented by many-to-many represented by

8 has responsibility for
ER diagram for example data model (not in 3NF – see next slides for an explanation) has FORM GRADE STUDENT achieved by members of achieves has has responsibility for TEACHING BODY contains TUTOR is a member

9 Forming Relationships between Entities
Try many to many. If that doesn’t work then try many to one. If that doesn’t work try one to many. If that doesn’t work then it has to be one to one. Note: I suggest this order of attempt as it helps avoid problems.

10 Database Normalization
A technique for designing relational database tables to minimize duplication of information which can lead to inconsistencies, leading to a loss of data integrity. Third Normal Form (3NF) eradicates (or at least minimizes) any data duplication.

11 To change an ER diagram into Third Normalised Form (3NF)
Example No many-to-many relationships. Removed by placing a link in between which has a many to one relationship to each of the other two entities. has FORM GRADE STUDENT achieved by members of achieves has One-to-one relationships should be removed (but not all mark schemes appear to force this but I suggest you always do so anyway). Removed by removing one of the entities and joining it to the entity that is left. has responsibility for TEACHING BODY contains TUTOR is a member

12 ER diagram for example data model in 3NF
LINK achieves STUDENT/ GRADE GRADE STUDENT members of achieved by has responsibility for FORM_TUTOR Joint entity is a member has TEACHING BODY

13 Third Normalised Form (3NF)
No many-to-many relationships. Removed by placing a link in between which has a many to one relationship to each of the other two entities. One-to-one relationships should be removed (but not all mark schemes appear to force this but I suggest you always do so anyway). Removed by removing one of the entities and joining it to the entity that is left.

14 Plenary A sports club runs a number of sports teams.
Each team is made up of a number of members of the club and each member may play for more than one team. Each team has a number of coaches, but the coach’s job is so time consuming that each coach can only coach one team. Represent the above information on an entity relation (ER) diagram, in 3rd normal form, stating the primary key for each entity. You can either draw this on paper or use the relationship images and text boxes on the next slide.

15

16 Plenary


Download ppt "Entity-Relationship (E-R) Diagrams"

Similar presentations


Ads by Google