3.1 CSIS 3310 Chapter 3 The Entity-Relationship Model Conceptual Data Modeling.

48
3. 3. 1 1 CSIS 3310 Chapter 3 The Entity-Relationship Model Conceptual Data Modeling

Transcript of 3.1 CSIS 3310 Chapter 3 The Entity-Relationship Model Conceptual Data Modeling.

3.3.11

CSIS 3310CSIS 3310

Chapter 3The Entity-Relationship

Model

Chapter 3The Entity-Relationship

Model

Conceptual Data Modeling

3.3.22

CSIS 3310CSIS 3310

SDLC Revisited – Data Modeling is an Analysis Activity

SDLC Revisited – Data Modeling is an Analysis Activity

Project Identification and Selection

Project Initiation and Planning

Analysis

Physical Design

Implementation

Maintenance

Logical Design

Purpose –thorough analysisDeliverable – functional system specifications

Database activity – conceptual data modelingcommunication between DB designer & user

3.3.33

CSIS 3310CSIS 3310 Business RulesBusiness Rules

• Statements that define or constrain some aspect of the business

• Assert business structure• Control/influence business behavior• Expressed in terms familiar to end

users• Automated through DBMS software

3.3.44

CSIS 3310CSIS 3310 A Good Business Rule is:A Good Business Rule is:

• Declarative – what, not how• Precise – clear, agreed-upon meaning• Atomic – one statement• Consistent – internally and externally• Expressible – structured, natural language• Distinct – non-redundant• Business-oriented – understood by

business people

3.3.55

CSIS 3310CSIS 3310Sample E-R DiagramSample E-R Diagram

3.3.66

CSIS 3310CSIS 3310 E-R Model ConstructsE-R Model Constructs

• Entity– Person: customer, vendor, supplier– Place: location, city, region, territory– Object: vehicle, monitor, part– Event: order, registration, renewal– Concept: expense, flight, project

• Entity Type versus Entity Instance• Entity Type versus System Input,

Output, or User

3.3.77

CSIS 3310CSIS 3310

Entity symbols

Relationship symbols

Attribute symbols

A special entity that is also a relationship

Basic E-R NotationBasic E-R Notation

3.3.88

CSIS 3310CSIS 3310

What Should an Entity Be?

What Should an Entity Be?

• SHOULD BE:– An object that will have many instances in the

database– An object that will be composed of multiple

attributes– An object that we are trying to model

• SHOULD NOT BE:– A user of the database system – An output of the database system (e.g. a

report)

3.3.99

CSIS 3310CSIS 3310

System userSystem user System outputSystem output

Appropriate entities

Inappropriate entitiesInappropriate entities

3.3.1010

CSIS 3310CSIS 3310 AttributesAttributes

• Attribute - property or characteristic of an entity type

• Classifications of attributes:–Simple versus Composite Attribute–Single-Valued versus Multivalued

Attribute–Derived Attributes– Identifier Attributes

3.3.1111

CSIS 3310CSIS 3310A composite attributeA composite attribute

3.3.1212

CSIS 3310CSIS 3310

Entity with a multivalued attribute (Skill) and derived attribute

(Years_Employed)

Entity with a multivalued attribute (Skill) and derived attribute

(Years_Employed)

Multivalued: an employee can have more than one skill

Derived from date employed and current date

3.3.1313

CSIS 3310CSIS 3310 E-R Model ConstructsE-R Model Constructs

• Identifier or Key

– An attribute (or combination of attributes) that uniquely identifies individual instances of an entity type.

• Simple Key versus Composite Key

• Candidate Key– an attribute that could be a key…satisfies

the requirements for being a key

3.3.1414

CSIS 3310CSIS 3310 Simple key attributeSimple key attribute

The key is underlined

3.3.1515

CSIS 3310CSIS 3310

Composite key attribute

Composite key attribute

The key is composed of two subparts

3.3.1616

CSIS 3310CSIS 3310

Criteria for Selecting Identifiers (Keys)

Criteria for Selecting Identifiers (Keys)

• Will not change in value.

• Will not be null.

• No intelligent identifiers–e.g. containing locations or people

that might change

• Substitute new, simple keys for long, composite keys.

3.3.1717

CSIS 3310CSIS 3310

Strong vs. Weak Entities, and

Identifying Relationships

Strong vs. Weak Entities, and

Identifying Relationships

• Strong entities – exist independently of other types of entities– has its own unique identifier– represented with single-line rectangle

• Weak entity– dependent on a strong entity…cannot exist on its

own– Does not have a unique identifier– represented with double-line rectangle

• Identifying relationship– links strong entities to weak entities– represented with double line diamond

3.3.1818

CSIS 3310CSIS 3310

Example of a weak entity

Example of a weak entity

3.3.1919

CSIS 3310CSIS 3310

Basic E-R NotationBasic E-R Notation

3.3.2020

CSIS 3310CSIS 3310 RelationshipsRelationships

• Relationship Types vs. Relationship Instances– The relationship type is modeled as the

diamond and lines between entity types

• Relationships can have attributes– These describe features pertaining to the

association between the entities in the relationship

• Two entities can have more than one type of relationship between them (multiple relationships)

3.3.2121

CSIS 3310CSIS 3310

Relationship type (Completes)

Relationship type (Completes)

3.3.2222

CSIS 3310CSIS 3310

Relationship instances

Relationship instances

3.3.2323

CSIS 3310CSIS 3310

Attribute on a relationship

Attribute on a relationship

3.3.2424

CSIS 3310CSIS 3310Associative EntityAssociative Entity

• Its an Entity – It’s a Relationship

• When should a relationship be an Associative Entity?

–All relationships involved are “many”

–Associative entity has independent meaning

–Has one or more non-key attributes

– Independent relationships

3.3.2525

CSIS 3310CSIS 3310

An associative entity (CERTIFICATE)

An associative entity (CERTIFICATE)

3.3.2626

CSIS 3310CSIS 3310

Degree of Relationships

Degree of Relationships

• Degree of a Relationship - number of entity types that participate in it.–Unary (or Recursive) Relationship

–Binary–Ternary

3.3.2727

CSIS 3310CSIS 3310

One entity related to another of the same entity type

Entities of two different types related to each other

Entities of three different types related to each other

Degree of relationships

Degree of relationships

3.3.2828

CSIS 3310CSIS 3310 Binary relationshipsBinary relationships

3.3.2929

CSIS 3310CSIS 3310 Unary relationshipsUnary relationships

3.3.3030

CSIS 3310CSIS 3310

Represents a bill-of -materials structure

This has a many-to-many relationship

A unary relationship with an attribute

A unary relationship with an attribute

3.3.3131

CSIS 3310CSIS 3310

An Associative EntityBill of Materials Structure

An Associative EntityBill of Materials Structure

3.3.3232

CSIS 3310CSIS 3310 Ternary relationshipsTernary relationships

3.3.3333

CSIS 3310CSIS 3310

A ternary relationship as an associative entity

A ternary relationship as an associative entity

3.3.3434

CSIS 3310CSIS 3310

Multivalued attribute vs. relationship. Alternative

approaches

Multivalued attribute vs. relationship. Alternative

approaches

3.3.3535

CSIS 3310CSIS 3310

Cardinality of RelationshipsCardinality of Relationships

• One – to – One– Each entity in the relationship will have

exactly one related entity

• One – to – Many– An entity on one side of the relationship can

have many related entities, but an entity on the other side will have a maximum of one related entity

• Many – to – Many– Entities on both sides of the relationship can

have many related entities on the other side

3.3.3636

CSIS 3310CSIS 3310

Cardinality ConstraintsCardinality Constraints

• The number of instances of one entity that can or must be associated with each instance of another entity–Minimum Cardinality

• If zero, then optionalIf zero, then optional• If one or more, then mandatoryIf one or more, then mandatory

–Maximum Cardinality–Mandatory One - when min & max both =

1

3.3.3737

CSIS 3310CSIS 3310 Cardinality notationCardinality notation

3.3.3838

CSIS 3310CSIS 3310

Mandatory cardinalities

Cardinality constraintsCardinality constraints

3.3.3939

CSIS 3310CSIS 3310

One optional, one mandatory cardinality

Cardinality constraintsCardinality constraints

3.3.4040

CSIS 3310CSIS 3310

Optional cardinalities with unary degree, one-to-one

relationship

Optional cardinalities with unary degree, one-to-one

relationship

3.3.4141

CSIS 3310CSIS 3310

Cardinality constraints in a ternary relationship

Cardinality constraints in a ternary relationship

3.3.4242

CSIS 3310CSIS 3310

Modeling Time-Dependent DataModeling Time-Dependent Data

• Time Stamps

3.3.4343

CSIS 3310CSIS 3310 Multiple RelationshipsMultiple Relationships

• More than one relationship between the same entity types

3.3.4444

CSIS 3310CSIS 3310

Multiple relationship with fixed cardinality constraintMultiple relationship with

fixed cardinality constraint

3.3.4545

CSIS 3310CSIS 3310

E-R Diagram for Pine Valley

3.3.4646

CSIS 3310CSIS 3310

Pine Valley Furniture User View 1: Orders for

customers

Pine Valley Furniture User View 1: Orders for

customers

3.3.4747

CSIS 3310CSIS 3310

Pine Valley FurnitureUser View 2: Orders for products

Pine Valley FurnitureUser View 2: Orders for products

3.3.4848

CSIS 3310CSIS 3310

Synonyms you should know…

Synonyms you should know…

Entity = relation = tableAttribute = columnInstance = row

rows

columns

table