entity relationship data model elizabeth george. introduction architect aeronautical engineers...

40
ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE

Upload: garey-charles

Post on 22-Dec-2015

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

ENTITY

RELA

TIONSHIP

DATA M

ODEL

ELIZABETH

GEORGE

Page 2: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

INTRODUCTION• Architect

• Aeronautical engineers

• Computer architects

• Traffic engineers

Page 3: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

DATA MODELData Model is made to transform the client requirements into specifications which are then given to the database builder

Page 4: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

BENEFITS OF DATA MODELING

• Focusing on essentials

• Ease of communication and understanding

• Product or process improvement

• Exploring alternatives

Page 5: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

TYPES OF MODELS• Descriptive

• Prescriptive

• Representative

Page 6: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

PHASES OF DATABASE MODELING• Conceptual modeling

• Logical design phase

• Implementation

Page 7: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

AN EXAMPLE: COMPANY DATABASE• The company database keeps track of a company’s employees,

departments, and projects. • The company is organized into departments. Each department has a

unique name, a unique number, and a particular employee who manages the department. We keep track of the start date when that employee began managing the department. A department may have several locations.

• A department controls a number of projects, each of which has a unique name, a unique number and a single location

• We store each employee’s name, social security number, address, salary, sex, and birth date. An employee is assigned to one department, but may work on several projects, which are not necessarily controlled by the same department. We keep track of the number of hours per week that an employee works on each project. We also keep track of the direct supervisor of each employee.

• We want to keep track of the dependents of each employee for insurance purposes. We keep each dependent’s first name, sex, birth date , and relationship to the employee.

Page 8: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

ENTITIES AND ENTITY SETS• Entity is a real or abstract object that can

be distinctly identified and is of interest.

• The part of and enterprise that is of interest is called the Universe of Discourse (UoD)

• An entity set is a set of objects called entity instances or entity occurrences

• An entity set is an individual object of a given entity type

Page 9: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

RELATIONSHIPS, CARDINALITY, ATTRIBUTES• A relationship is an association among

entities.

• Cardinality Ratio of a relationship: It is the maximum number of relationship instances that an entity can participate in.

• Information about entities which are of interest are called attributes.

Page 10: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

ATTRIBUTESThe description of each entity instance in

an entity set and the information of interest is called entity attributes

10

Page 11: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

TYPES OF ATTRIBUTESimple or Composite

Single or Multi-valued

Stored or Derived

Required or Optional

Null attributes

11

Page 12: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

ENTITY KEY, CANDIDATE KEY AND SUPER KEY

A group of attributes (possibly one) used for identifying each entity in an entity set is called an entity key

Primary key – is an attribute or a set of attributes that uniquely identifies a specific instance of an entity.

Every entity in an ER model must have a primary key

12

Page 13: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

CANDIDATE KEYWhen an entity has more than one

attribute (or a set of attributes) that can serve as a primary key, each of such keys is called a candidate key.

One and only one of the candidate keys is chosen as the primary key for the entity

13

Page 14: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

WEAK ENTITYWeak entity – an entity that depends on

another entity for identification

Weak entity relation – a relation that is used for identifying entities

Regular entity relation – a relation not used for identifying entities

14

Page 15: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

NAMING CONVENTIONS:ENTITIES

1. Each entity name should come from the entity description

2. Each entity name should be a noun3. The first letter should be a uppercase4. Underscores should join the words5. Names of the entities should be

meaningful and should not conflict with other entity names

15

Page 16: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

NAMING CONVENTIONS: RELATIONSHIPS

1. Each relationship name should be a verb that fits the sentence structure

2. Can use underscores to join the words

16

Page 17: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

CROW’S FOOT DIAGRAMMATIC NOTATION

1:1 relation

17

Employee Office

Attributes Attributes

Page 18: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

MANY TO ONE .. ETC…

18

n:1 relation

Employee Office

Attributes Attributes

Page 19: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

CARDINALITY RATIOS• One – to – One

• One – to – Many

• Many – to – Many

19

Page 20: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

WEAK ENTITY TYPESA weak entity is also called a subordinate

entity since its existence depends on another entity. This is called existence dependence.

The primary key of a weak entity is found by taking the primary key of the strong entity on which it is existence dependent combined with the discriminator of the weak entity set.

Page 21: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

WEAK ENTITY SETS (CONT.)

We depict a weak entity set by double rectangles.

We underline the discriminator of a weak entity set with a dashed line.

payment_number – discriminator of the payment entity set

Primary key for payment – (loan_number, payment_number)

Page 22: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

GENERALIZATION, SPECIALIZATION AND AGGREGATION“is a” relationFor example: Car “is a” vehicle

An entity cannot exist in a database which merely belongs to subclass, it should also belong to the super class

The characteristics of car apply to all the vehicle

If a general class entity participates in a particular relationship type, then the specialized class entity should also participate in that relation

22

Page 23: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

SPECIALIZATIONThe Process of creating a subclass out of

a given entity type is called specialization

Ford Figo “is a” car “is a” vehicle

The reverse process of taking 2 or more entity types and clubbing them under a common super class is called generalization

23

Page 24: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

AGGREGATIONAggregates a particular ER schema and

makes it into an entity at higher level of abstraction

“contains”

Offering “contains” offer

Mostly used for Knowledge Management like ontology process

24

Page 25: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

Aggregation Consider the ternary relationship works-on, which we saw earlier

Suppose we want to record managers for tasks performed by an employee at a branch

25

Page 26: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

E-R Diagram With Aggregation

26

Page 27: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

27

Page 28: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

28

Page 29: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

TYPES OF GENERALIZATION AND SPECIALIZATION

Disjoint

Overlapping

Union

29

Page 30: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

30

Page 31: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

31

Page 32: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

32

Page 33: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

SPECIALIZATION

Is the process of defining a set of subclasses of a superclass

The set of subclasses is based upon some distinguishing characteristics of the entities in the superclass

Example: {SECRETARY, ENGINEER, TECHNICIAN} is a specialization of EMPLOYEE based upon job type.

May have several specializations of the same superclass

33

Page 34: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

EXAMPLE OF A SPECIALIZATION

34

Page 35: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

GENERALIZATIONThe reverse of the specialization process Several classes with common features are

generalized into a superclass; original classes become its subclasses

Example: CAR, TRUCK generalized into VEHICLE; both CAR, TRUCK become subclasses of the superclass VEHICLE.

We can view {CAR, TRUCK} as a specialization of VEHICLE

Alternatively, we can view VEHICLE as a generalization of CAR and TRUCK

35

Page 36: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

UNION TYPE

Example: Database for vehicle registration, vehicle owner can be a person, a bank (holding a lien on a vehicle) or a company.

Category (subclass) OWNER is a subset of the union of the three superclasses COMPANY, BANK, and PERSON

A category member must exist in at least one of its superclasses

Note: The difference from shared subclass, which is subset of the intersection of its superclasses (shared subclass member must exist in all of its superclasses).

36

Page 37: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

EXAMPLE OF CATEGORIES(UNION TYPES)

37

Page 38: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

SELF STUDY

ER diagram conventions/ notations

Strengths and Weakness of ER Diagram

The database design process (step by step)i. Requirement analysisii. Identify entity setsiii. Identify relationship setsiv. ER diagramv. Value sets and attributesvi. Primary keysvii. Prototypeviii. Implementation

38

Page 39: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

REFERENCES

Database Management Systems, G.K. Gupta

www.nptel.ac.in

39

Page 40: ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers Computer architects Traffic engineers

THANK YOU!

40