entity relationships

17
Entity Relationships A337

Upload: jeri

Post on 16-Feb-2016

26 views

Category:

Documents


0 download

DESCRIPTION

Entity Relationships. A337. Data Stores-Specific Diagrams. Included on both Flowcharts and DFDs There are also rules related to data stores. For example Can there be multiple invoices with the same number? Can a customer have more than one address? - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Entity Relationships

Entity RelationshipsA337

Page 2: Entity Relationships

Data Stores-Specific Diagrams• Included on both Flowcharts and DFDs

• There are also rules related to data stores. For example

– Can there be multiple invoices with the same number?– Can a customer have more than one address?– Can an address belong to more than one customer?

Page 3: Entity Relationships

Relationships within the Relational DatabaseMaximum Cardinality (the “outside” symbols)

• 1:M relationship

• M:N relationships

• 1:1 relationship

Minimum Cardinality (the “inside” symbols)

• 0 optional

• | mandatory

Page 4: Entity Relationships

The 1:1 Relationship• One entity can be related to only one other entity, and

vice versa

• Could indicate that two entities actually belong in the same table

• Sometimes 1:1 relationships are appropriate

Database Systems: Design, Implementation, & Management, 6 th Edition, Rob & Coronel

Page 5: Entity Relationships

The 1:1 Relationship Between PROFESSOR and DEPARTMENT

Page 6: Entity Relationships

The Implemented 1:1 Relationship Between PROFESSOR and DEPARTMENT

Page 7: Entity Relationships

The 1:M Relationship• Indicates that for every row in one table, there may

be multiple related records

• Depends on the situation

• Customer to Address can be

– 1:1 (e.g., HOA)– 1:M (e.g., Online retailer - mailing, billing, etc)

Page 8: Entity Relationships

The 1:M Relationship Between COURSE and CLASS

Page 9: Entity Relationships

The Implemented 1:M RelationshipBetween COURSE and CLASS

Page 10: Entity Relationships

The M:N Relationship• Implemented by using a pair of 1:M relationships

• Can require creating a composite entity or bridge entity

• Composite entity table must contain at least the primary keys of original tables

Page 11: Entity Relationships

The ERD’s M:N Relationship Between STUDENT and CLASS

Page 12: Entity Relationships

The M:N Relationship Between STUDENT and CLASS

Page 13: Entity Relationships

Changing the M:N Relationship to Two 1:M Relationships

Page 14: Entity Relationships

Converting the M:N Relationship into Two 1:M Relationships

Page 15: Entity Relationships

The Expanded Entity Relationship Model

Page 16: Entity Relationships

“Key” terms• An entity is something of importance to a user

that needs to be represented in a database.

• An entity represents one theme or topic and is represented by a table.

• The table dimensions, like a matrix, consist of rows (tuples) and columns (attributes).

• A table may be related to other tables (i.e., a relationship).

Page 17: Entity Relationships

Relationship Key Example

Project

Proj_Num

Proj_Name

MgrID

Manager

MgrID

MgrName

Foreign Key

Primary Key

Relationship