ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers...

Post on 22-Dec-2015

221 views 0 download

Tags:

Transcript of ENTITY RELATIONSHIP DATA MODEL ELIZABETH GEORGE. INTRODUCTION Architect Aeronautical engineers...

ENTITY

RELA

TIONSHIP

DATA M

ODEL

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

BENEFITS OF DATA MODELING

• Focusing on essentials

• Ease of communication and understanding

• Product or process improvement

• Exploring alternatives

TYPES OF MODELS• Descriptive

• Prescriptive

• Representative

PHASES OF DATABASE MODELING• Conceptual modeling

• Logical design phase

• Implementation

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.

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

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.

ATTRIBUTESThe description of each entity instance in

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

10

TYPES OF ATTRIBUTESimple or Composite

Single or Multi-valued

Stored or Derived

Required or Optional

Null attributes

11

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

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

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

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

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

CROW’S FOOT DIAGRAMMATIC NOTATION

1:1 relation

17

Employee Office

Attributes Attributes

MANY TO ONE .. ETC…

18

n:1 relation

Employee Office

Attributes Attributes

CARDINALITY RATIOS• One – to – One

• One – to – Many

• Many – to – Many

19

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.

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)

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

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

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

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

E-R Diagram With Aggregation

26

27

28

TYPES OF GENERALIZATION AND SPECIALIZATION

Disjoint

Overlapping

Union

29

30

31

32

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

EXAMPLE OF A SPECIALIZATION

34

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

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

EXAMPLE OF CATEGORIES(UNION TYPES)

37

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

REFERENCES

Database Management Systems, G.K. Gupta

www.nptel.ac.in

39

THANK YOU!

40