Top Banner
Conceptual Design Conceptual Design Lecture - 2 Lecture - 2 Database Development Database Development
25
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Conceptual Design Lecture - 2 Database Development.

Conceptual Design Conceptual Design Lecture - 2Lecture - 2

Database DevelopmentDatabase Development

Page 2: Conceptual Design Lecture - 2 Database Development.

At the end of this lectureAt the end of this lecture

You will be able to identify and represent You will be able to identify and represent on a diagram:on a diagram:– a strong entitya strong entity– a weak entitya weak entity– three association typesthree association types– a recursive relationshipa recursive relationship– a unique identifiera unique identifier– an optional relationshipan optional relationship– a required relationshipa required relationship

from a given description.from a given description.

Page 3: Conceptual Design Lecture - 2 Database Development.

Basic constructs of theBasic constructs of theEntity Relationship ModelEntity Relationship Model

EntityEntity Representation of an Entity on an ER Representation of an Entity on an ER

diagram is:diagram is:– a box with square corners a box with square corners – labelled with the entity name.labelled with the entity name.

Note – the entity name is always singularNote – the entity name is always singular

Student

Page 4: Conceptual Design Lecture - 2 Database Development.

Basic constructs of theBasic constructs of theEntity Relationship ModelEntity Relationship Model

Entity typesEntity types An Entity may be classified as either An Entity may be classified as either

a weak entity or a strong entitya weak entity or a strong entity

Page 5: Conceptual Design Lecture - 2 Database Development.

Basic constructs of theBasic constructs of theEntity Relationship ModelEntity Relationship Model

Weak EntityWeak Entity Representation of a Weak Entity on Representation of a Weak Entity on

an ER diagram is:an ER diagram is:– a box with rounded corners a box with rounded corners – labelled with the entity name (singular)labelled with the entity name (singular)

NextOfKin

Page 6: Conceptual Design Lecture - 2 Database Development.

Basic constructs of theBasic constructs of theEntity Relationship ModelEntity Relationship Model

Strong EntityStrong Entity By default an entity which is not a By default an entity which is not a

weak entity is a strong entity.weak entity is a strong entity.

Student

Page 7: Conceptual Design Lecture - 2 Database Development.

The ER ModelThe ER Model

DescriptionDescription

An order may only be placed with a An order may only be placed with a supplier who has been validated by supplier who has been validated by the company.the company.

Two possible entities from the Two possible entities from the description aredescription are– OrderOrder– SupplierSupplier

Page 8: Conceptual Design Lecture - 2 Database Development.

The ER ModelThe ER Model

What kind of entity is an Order?What kind of entity is an Order?– Weak entity?Weak entity?– Strong entity?Strong entity?

What kind of entity is an Supplier?What kind of entity is an Supplier?– Weak entity?Weak entity?– Strong entity?Strong entity?

Page 9: Conceptual Design Lecture - 2 Database Development.

The ER ModelThe ER Model

What kind of entity is an Order?What kind of entity is an Order?– A Weak entity!A Weak entity!

What kind of entity is an Supplier?What kind of entity is an Supplier?– Strong entity!Strong entity!

Supplier

Order

Page 10: Conceptual Design Lecture - 2 Database Development.

ER Model Relationship ER Model Relationship TypesTypes

Relationships we will use.Relationships we will use. One to OneOne to One One to ManyOne to Many Many to ManyMany to Many InheritanceInheritance

Page 11: Conceptual Design Lecture - 2 Database Development.

ER Model Relationship ER Model Relationship TypesTypes

One to OneOne to One– An employee is allocated a single An employee is allocated a single

parking space, a parking space belongs parking space, a parking space belongs to only one employee.to only one employee.

1:1Employee ParkingSpace

Page 12: Conceptual Design Lecture - 2 Database Development.

ER Model Relationship ER Model Relationship TypesTypes

One to ManyOne to Many– A department has many employees A department has many employees

assigned to it, each employee is assigned to it, each employee is assigned to only one department.assigned to only one department.

1:MDepartment Employee

Page 13: Conceptual Design Lecture - 2 Database Development.

ER Model Relationship ER Model Relationship TypesTypes

Many to ManyMany to Many– An employee attends many staff An employee attends many staff

development sessions, each staff development sessions, each staff development session is attended by development session is attended by many employees.many employees.

N:MStaffDevSess Employee

Page 14: Conceptual Design Lecture - 2 Database Development.

ER Model Relationship ER Model Relationship TypesTypes

Many to ManyMany to Many– An employee attends many staff An employee attends many staff

development sessions, each staff development sessions, each staff development session is attended by development session is attended by many employees.many employees.

N:MStaffDevSess Employee

Page 15: Conceptual Design Lecture - 2 Database Development.

ER Model Relationship ER Model Relationship TypesTypes

InheritanceInheritance– A technician is a A technician is a

kind of employee kind of employee about whom we about whom we wish to record, in wish to record, in addition to his addition to his other attributes, his other attributes, his highest technical highest technical qualification.qualification.

Technician

Employee

Page 16: Conceptual Design Lecture - 2 Database Development.

ER Model Relationship ER Model Relationship ExistenceExistence

In Object Oriented Software In Object Oriented Software Development you could show if an Development you could show if an association was optional or required association was optional or required as follows.as follows.

Optional related class instance was Optional related class instance was shown as 0..*shown as 0..*– An association between an instance of An association between an instance of

one class with Zero or more related one class with Zero or more related instances from another classinstances from another class

Page 17: Conceptual Design Lecture - 2 Database Development.

ER Model Relationship ER Model Relationship ExistenceExistence

Required related class instance was Required related class instance was shown as 1..*shown as 1..*– An association between a minimum of An association between a minimum of

one or more related class instances.one or more related class instances. In ER diagrams you do not use the In ER diagrams you do not use the

same notationsame notation

Page 18: Conceptual Design Lecture - 2 Database Development.

ER Model Relationship ER Model Relationship ExistenceExistence

In the ER model optional association In the ER model optional association existence is shown as.existence is shown as.

An employee may be a member of An employee may be a member of one of the works football teams.one of the works football teams.

1:MFootballTeam Employee

Page 19: Conceptual Design Lecture - 2 Database Development.

ER Model Relationship ER Model Relationship ExistenceExistence

In the ER model mandatory In the ER model mandatory association existence is shown as.association existence is shown as.

An employee must be a member of An employee must be a member of one of the unions recognised by the one of the unions recognised by the company.company.

1:MUnion Employee

Page 20: Conceptual Design Lecture - 2 Database Development.

ER Model RelationshipER Model Relationship

Recursive relationship.Recursive relationship. An employee may also be a An employee may also be a

manager. A number of employees manager. A number of employees are managed by a single managerare managed by a single manager

Employee

1:MEmployee Manager

Page 21: Conceptual Design Lecture - 2 Database Development.

AttributesAttributes

What is an attribute?What is an attribute? An attribute is a piece of information An attribute is a piece of information

about the object or event that we wish about the object or event that we wish to store in our database.to store in our database.

It can be said to describe the object.It can be said to describe the object. An example of some possible attributes An example of some possible attributes

for Employee could be EmployeeID, for Employee could be EmployeeID, EmpFirstName, EmpSurnameEmpFirstName, EmpSurname

Page 22: Conceptual Design Lecture - 2 Database Development.

AttributesAttributes

Page 23: Conceptual Design Lecture - 2 Database Development.

ER Model Representation of ER Model Representation of AttributesAttributes

Only attributes which uniquely Only attributes which uniquely identify an entity will be represented identify an entity will be represented on your ER diagram.on your ER diagram.

A key attribute may be represented A key attribute may be represented as followsas follows

Employee

EmployeeID

Page 24: Conceptual Design Lecture - 2 Database Development.

ER Model Representation of ER Model Representation of AttributesAttributes

What about other attributes?What about other attributes?– These will be put on a diagram script.These will be put on a diagram script.

More about this next week.More about this next week.

Page 25: Conceptual Design Lecture - 2 Database Development.

ER Diagram SummaryER Diagram Summary

How to representHow to represent– an Entity.an Entity.– an Associationan Association– InheritanceInheritance– Recursive RelationshipRecursive Relationship– Key FieldKey Field