Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

13
Databases and E-R Databases and E-R Diagrams Diagrams Access/IPS Access/IPS Walsall College of Arts & Walsall College of Arts & Technology Technology

Transcript of Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

Page 1: Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

Databases and E-R Databases and E-R DiagramsDiagrams

Access/IPSAccess/IPS

Walsall College of Arts & Walsall College of Arts & TechnologyTechnology

Page 2: Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

November 2002November 2002 Walsall College of Arts & TechnologWalsall College of Arts & Technologyy

22

What we are going to cover:What we are going to cover:

What is a database and why do we use them?What is a database and why do we use them? What are Entities, Attributes & Relationships What are Entities, Attributes & Relationships

(in terms of databases)?(in terms of databases)? What is an Entity-Relationship diagram and What is an Entity-Relationship diagram and

why are they used?why are they used?

Anything else we feel like discussingAnything else we feel like discussing

Page 3: Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

November 2002November 2002 Walsall College of Arts & TechnologWalsall College of Arts & Technologyy

33

What is a database?What is a database?

Technical version:Technical version: ““A collection of persistent data in a fixed store”A collection of persistent data in a fixed store” What?What?

English version:English version: Information held about something that can be Information held about something that can be

looked at more than oncelooked at more than once Clear as mud, eh?Clear as mud, eh?

Page 4: Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

November 2002November 2002 Walsall College of Arts & TechnologWalsall College of Arts & Technologyy

44

What makes up a database?What makes up a database?

A database is made up of:A database is made up of: TablesTables AttributesAttributes RelationshipsRelationships

More about these in a bitMore about these in a bit

Page 5: Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

November 2002November 2002 Walsall College of Arts & TechnologWalsall College of Arts & Technologyy

55

Why use Databases?Why use Databases?

Quicker referenceQuicker reference Take up less space – no filing cabinetsTake up less space – no filing cabinets Hold more information in a smaller spaceHold more information in a smaller space Information remains indexed with new entriesInformation remains indexed with new entries Less paper = less risk of fire!Less paper = less risk of fire! And finally…..And finally….. Because they’re really good!Because they’re really good!

Page 6: Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

November 2002November 2002 Walsall College of Arts & TechnologWalsall College of Arts & Technologyy

66

What are Entities, Attributes and What are Entities, Attributes and Relationships?Relationships?

Entities are things we hold information aboutEntities are things we hold information about Eg. A Student or a CourseEg. A Student or a Course

Attributes are the different categories of information Attributes are the different categories of information for each entity, also known as Fields. for each entity, also known as Fields. Eg. Student Name, Number, etcEg. Student Name, Number, etc A collection of Attributes is known as a RecordA collection of Attributes is known as a Record

Relationships are the connections between EntitiesRelationships are the connections between Entities Eg. A Student Eg. A Student enrolsenrols in a Course in a Course

Page 7: Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

November 2002November 2002 Walsall College of Arts & TechnologWalsall College of Arts & Technologyy

77

E-R DiagramsE-R Diagrams

Entity-Relationship DiagramsEntity-Relationship Diagrams What are they?What are they?

Diagrams to show how Entities are related to each Diagrams to show how Entities are related to each otherother

This may seem too easy, but it really is that This may seem too easy, but it really is that simple!simple!

What does one look like?What does one look like? We’ll see in a momentWe’ll see in a moment

Page 8: Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

November 2002November 2002 Walsall College of Arts & TechnologWalsall College of Arts & Technologyy

88

3 of a kind3 of a kind

There are 3 kinds of RelationshipThere are 3 kinds of Relationship One to OneOne to One One to ManyOne to Many Many to ManyMany to Many

More explanation is required…..More explanation is required….. The best way to explain these, is through The best way to explain these, is through

examplesexamples

Page 9: Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

November 2002November 2002 Walsall College of Arts & TechnologWalsall College of Arts & Technologyy

99

One to OneOne to One

We’ll use Husbands and WivesWe’ll use Husbands and Wives If we have an entity “Husband” and an entity If we have an entity “Husband” and an entity

“Wife”“Wife” In English Law, In English Law, OneOne Husband can have Husband can have OneOne

Wife and vice-versaWife and vice-versa

HUSBAND WIFE

Page 10: Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

November 2002November 2002 Walsall College of Arts & TechnologWalsall College of Arts & Technologyy

1010

One to ManyOne to Many

We’ll use Football Teams and PlayersWe’ll use Football Teams and Players If we have an Entity “Team” and an Entity If we have an Entity “Team” and an Entity

“Player”“Player” A Team can have A Team can have manymany Players, but a Player Players, but a Player

can only play for can only play for oneone Team Team

TEAM PLAYER

Page 11: Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

November 2002November 2002 Walsall College of Arts & TechnologWalsall College of Arts & Technologyy

1111

Many to ManyMany to Many

We’ll use Films and FilmstarsWe’ll use Films and Filmstars If we have an entity “Film” and an entity If we have an entity “Film” and an entity

“Filmstar”“Filmstar” A Film has A Film has manymany Filmstars and a Filmstar can Filmstars and a Filmstar can

be in be in manymany Films. Films.

FILM FILMSTAR

Page 12: Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

November 2002November 2002 Walsall College of Arts & TechnologWalsall College of Arts & Technologyy

1212

ExerciseExercise

Work out the relationships between, and draw Work out the relationships between, and draw a diagram for the following entitiesa diagram for the following entities

Computer and Computer GameComputer and Computer Game Company and Branch Office Company and Branch Office Veterinary Surgeon & PracticeVeterinary Surgeon & Practice Customer Car & Registered OwnerCustomer Car & Registered Owner

Page 13: Databases and E-R Diagrams Access/IPS Walsall College of Arts & Technology.

November 2002November 2002 Walsall College of Arts & TechnologWalsall College of Arts & Technologyy

1313

AcknowledgementAcknowledgement

Some of the material in this presentation was Some of the material in this presentation was taken from a presentation by Janet Hardy, taken from a presentation by Janet Hardy, Lecturer in Computer Science dept, University Lecturer in Computer Science dept, University of Wales, Aberystwythof Wales, Aberystwyth

Thanks Janet!Thanks Janet!