Download presentation
Presentation is loading. Please wait.
1
Mr C Johnston Sidney Stringer Academy
BTEC NCF IT Unit 02 Creating Systems to Manage Information Lesson 03 – Entity Relationships Mr C Johnston Sidney Stringer Academy
2
Learning Outcome Understand basic entity relationships
Understand how entity relationships can be used to keep data integral Able to model and apply entity relationship diagrams to situations
3
STARTER Look at the database table below… Are there any issues?
4
Problems with the Database
Repetition of data: Supplier name and phone number entered in each record, Wastes space Inconsistency in data: Same supplier spelt differently, Same phone number has mistakes
5
The Solution To spilt the database up into different entities!
In this model we would create two entities One for the products One for the suppliers So that the database works we need to join the two entities together to form a relationship.
6
Entity Relationships A relationship is a link or association between entities It represents the real life relationship between entities e.g. Normally one dentist has many patients There are three types of relationships in database land One – to – One A husband has one wife (at a time) AND a wife has one husband (as a time) One – to – Many A ward holds many patients A landlord has many houses Many – to – Many One album can feature many artists BUT one artist can feature on many albums A chocolate bas has many ingredients BUT An ingredient can be used in many different chocolate bars
7
QUESTION What is the relationship between these two entities?
One supplier has many products One supplier has many products BUT one product can come from many suppliers
8
Entity Relationships Diagrams
This is a way of showing relationships between entities, Entity names are always written in capitals and appear in rectangles, Lines join entities together and have: Symbol to show the degree of the relationship, A description to show the name of the relationship,
9
Entity Relationships Diagrams
HUSBAND WIFE has WARD PATIENT holds ALBUM SINGERS features
10
Relationship Rules Within database land it is not feasible or sensible for all three relationships to exist ONE-to-ONE relationships normally get collapsed and one entity becomes an attribute of the other MANY-to-MANY relationships are very common BUT there needs to be a way the DBMS knows which data is which
11
ONE-to-ONE Collapse CUSTOMER DETAIL has custno lastname firstname 0001
henry john 0002 smith adam 0003 johnson mary 0004 bailey harry 0005 morgan alex custno height weight dateofbirth 0001 181 75 03/05/1960 0002 179 82 06/08/1974 0003 171 65 04/01/1955 0004 185 93 05/05/1980 0005 168 71 09/09/1975 custno lastname firstname height weight dateofbirth 0001 henry lohn 181 75 03/05/1960 0002 smith adam 179 82 06/08/1974 0003 johnson mary 171 65 04/01/1955 0004 bailey harry 185 93 05/05/1980 0005 morgan alex 168 71 09/09/1975
12
Many–to–Many Resolve Many - to – Many relationships are not allowed so we have to resolve them some how. To do this we introduce an additional entity between them Thus creating 2 one-to– many relationships.
13
ACTIVITY Draw an entity relationship diagram to show the relationship between A product and its components A house and street A pet owner and their pets Draw an entity relationship diagram providing a many – to – many resolve to show the relationship between Ferries and their routes Customers and videos in a rental shop Students and courses in a school Patients and medicine in a hospital
14
EXTENSION ACTIVITY List a further three situations where a many-to-many relationship exists between two entities – give them to somebody else to draw the required ERD Carry out some research to discover how we link the entities together within a DBMS
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.