entity relationship diagrams

13
Entity Relationship Diagrams 3.3.1

Upload: aretha-olsen

Post on 30-Dec-2015

34 views

Category:

Documents


0 download

DESCRIPTION

Entity Relationship Diagrams. 3.3.1. This presentation covers. What is an Entity What is an Entity Relationship Diagram? Different types of relationships. Introduction. Systems can be confusing things. To help people understand what they are trying to design they often use diagrams. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Entity Relationship Diagrams

Entity Relationship Diagrams

3.3.1

Page 2: Entity Relationship Diagrams

This presentation covers

• What is an Entity

• What is an Entity Relationship Diagram?

• Different types of relationships

Page 3: Entity Relationship Diagrams

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

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

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

Entities

• Strictly speaking...

• The is also an entity...as it too is

made up of different attributes!

Page 7: Entity Relationship Diagrams

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

One-to-One

• Assuming a teacher only taught in one classroom in a school...

Teacher Classroom

Page 9: Entity Relationship Diagrams

One-to-Many

• A teacher has many lessons but a lesson can only have one teacher.

Teacher Lesson

Page 10: Entity Relationship Diagrams

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

Fixing Many-to-Many

• A third table is added to create two One-to-Many relationships.

Teacher Students

Class

Page 12: Entity Relationship Diagrams

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

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.