Entity Relationship Diagrams
-
Upload
aretha-olsen -
Category
Documents
-
view
34 -
download
0
description
Transcript of Entity Relationship Diagrams
![Page 1: Entity Relationship Diagrams](https://reader036.fdocuments.us/reader036/viewer/2022082517/56812bd4550346895d9039ec/html5/thumbnails/1.jpg)
Entity Relationship Diagrams
3.3.1
![Page 2: Entity Relationship Diagrams](https://reader036.fdocuments.us/reader036/viewer/2022082517/56812bd4550346895d9039ec/html5/thumbnails/2.jpg)
This presentation covers
• What is an Entity
• What is an Entity Relationship Diagram?
• Different types of relationships
![Page 3: Entity Relationship Diagrams](https://reader036.fdocuments.us/reader036/viewer/2022082517/56812bd4550346895d9039ec/html5/thumbnails/3.jpg)
Introduction• Systems can be confusing things.
• To help people understand what they are trying to design they often use diagrams.
• There are different styles of diagrams including:– Entity Relationship Diagrams– State Transition Diagrams– Data Flow Diagrams– Flowcharts
• The type of diagram used will depend on the system being designed but a combination of diagrams can be used on the same project.
![Page 4: Entity Relationship Diagrams](https://reader036.fdocuments.us/reader036/viewer/2022082517/56812bd4550346895d9039ec/html5/thumbnails/4.jpg)
Entity Relationship Diagrams
• Also known as ERDs.
• This diagram represents entities and the relationships between them.
• We have already looked at these diagrams when we covered Normalisation back in AS Level...so this will be more of a refresher topic!
![Page 5: Entity Relationship Diagrams](https://reader036.fdocuments.us/reader036/viewer/2022082517/56812bd4550346895d9039ec/html5/thumbnails/5.jpg)
Entities
• Entities are ‘things’.
• Each entity is made up of attributes.
• For example, a is an entity.
• It is made up of leaves... and other things.
![Page 6: Entity Relationship Diagrams](https://reader036.fdocuments.us/reader036/viewer/2022082517/56812bd4550346895d9039ec/html5/thumbnails/6.jpg)
Entities
• Strictly speaking...
• The is also an entity...as it too is
made up of different attributes!
![Page 7: Entity Relationship Diagrams](https://reader036.fdocuments.us/reader036/viewer/2022082517/56812bd4550346895d9039ec/html5/thumbnails/7.jpg)
Types of Relationship
• There are different types of relationship which you need to be aware of:
– One-to-One– One-to-Many– Many-to-Many
![Page 8: Entity Relationship Diagrams](https://reader036.fdocuments.us/reader036/viewer/2022082517/56812bd4550346895d9039ec/html5/thumbnails/8.jpg)
One-to-One
• Assuming a teacher only taught in one classroom in a school...
Teacher Classroom
![Page 9: Entity Relationship Diagrams](https://reader036.fdocuments.us/reader036/viewer/2022082517/56812bd4550346895d9039ec/html5/thumbnails/9.jpg)
One-to-Many
• A teacher has many lessons but a lesson can only have one teacher.
Teacher Lesson
![Page 10: Entity Relationship Diagrams](https://reader036.fdocuments.us/reader036/viewer/2022082517/56812bd4550346895d9039ec/html5/thumbnails/10.jpg)
Many-to-Many
• A teacher has many students and a student can have many teachers.
• Many-to-Many relationships are never ideal so a third table is often created.
Teacher Students
![Page 11: Entity Relationship Diagrams](https://reader036.fdocuments.us/reader036/viewer/2022082517/56812bd4550346895d9039ec/html5/thumbnails/11.jpg)
Fixing Many-to-Many
• A third table is added to create two One-to-Many relationships.
Teacher Students
Class
![Page 12: Entity Relationship Diagrams](https://reader036.fdocuments.us/reader036/viewer/2022082517/56812bd4550346895d9039ec/html5/thumbnails/12.jpg)
Developing the ERD
• You must know the following things:
– The entities– The attributes for each entity– The primary key for the entity– The foreign key(s) in each entity
![Page 13: Entity Relationship Diagrams](https://reader036.fdocuments.us/reader036/viewer/2022082517/56812bd4550346895d9039ec/html5/thumbnails/13.jpg)
Something for you to do...
• A small guesthouse registers its guests on a database.
• Three of the entities used in the database are CUSTOMER, ROOM and BOOKING.
• Draw an ERD to represent this part of the database.