cs317 file and database systems -...

36
September 6, 2017 Sam Siewert CS317 File and Database Systems Lecture 2 – Basic ER Models Part-2 http://dilbert.com/strips/comic/2012-08-14/

Upload: others

Post on 21-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

September 6, 2017 Sam Siewert

CS317File and Database Systems

Lecture 2 – Basic ER ModelsPart-2

http://dilbert.com/strips/comic/2012-08-14/

Page 2: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

Reminders…Assignement #1, Due Today

Late Due Date (10% penalty) is Monday

Assignment #2, Available on Sunday Morning

Sam Siewert 2

Page 3: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

DBMS Analysis and Design

Basic ER-Models

Sam Siewert

3

Page 4: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

For Discussion…SA/SD – Focused on Dataflow and Structure

1. SA/SD Included a Data Dictionary which is Data on Data (Meta-data) that describes DBMS Tables (the Schema)

2. Entities in a DBMS ERD Contain Meta-data

3. Chen’s Goal in 1976 with the Entity Relationship Model Was to Show the Structure of Relations and Cardinality

4. Work in DBMS at the time Was Normalization of Relational Models (Elimination of Redundant Data in Tables, Related through Foreign Keys)

5. Compare to Relational Model, Network Model, Hierarchical Model (pages 46-49 in Connolly-Begg - Scanned and Uploaded to Canvas)

6. UML – ER Model comparable to UML Class Diagram (not identical), EER (Enhanced ER Model) for Superclass and Subclass Relationships

Sam Siewert 4

Page 5: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

DBMS Development Lifecycle

ER Models - DBMS Chapter 2

Sam Siewert

5

Page 6: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

DreamHome ER ModelCompare to DreamHome Relational Model

Sam Siewert 6

Tables

1) Staff2) Branch3) Registration

(Ternary Registers)

• Lease4) Client• Preference5) PropertyForRent• Newspaper6) PrivateOwner• Business Owner7) Viewing

(Conceptual)

Page 7: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

7

Examples of Entity Types

Page 8: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

8

Semantic net of Has relationship type

Page 9: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

9

ER diagram of Branch Has Staff relationship

Page 10: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

10

Relationship Types

Degree of a Relationship– Number of participating entities in relationship.

Relationship of degree :– two is binary – three is ternary– four is quaternary.

Page 11: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

11

Ternary relationship called Registers

Page 12: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

12

Quaternary relationship called Arranges

E.g. Staff arranges a Viewing on behalf of a PrivateOwner supported by a Branch

Page 13: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

13

ER diagram of Staff and Branchentities and their attributes

Page 14: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

DreamHome SchemaWorking Example DB from old Textbook

Can Create from DreamHome version 1.0

Used in Examples in Class

Sam Siewert 14

Page 15: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

15

Strong entity type called Client and weak entity type called Preference

Page 16: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

16

Relationship called Advertises with attributes

Page 17: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

17

Structural Constraints

The most common degree for relationships is binary.

Binary relationships are generally referred to as being:– one-to-one (1:1)– one-to-many (1:*)– many-to-many (*:*)

Page 18: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

18

Semantic net of Staff Manages Branchrelationship type

Page 19: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

19

Multiplicity of Staff Manages Branch(1:1) relationship

Page 20: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

20

Semantic net of Staff Oversees PropertyForRent relationship type

Page 21: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

21

Multiplicity of Staff OverseesPropertyForRent (1:*) relationship type

Page 22: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

22

Semantic net of Newspaper AdvertisesPropertyForRent relationship type

Page 23: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

23

Multiplicity of Newspaper AdvertisesPropertyForRent (*:*) relationship

Page 24: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

24

Semantic net of ternary Registersrelationship with values for Staff and

Branch entities fixed

Page 25: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

25

Multiplicity of ternary Registersrelationship

Page 26: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

26

Summary of multiplicity constraints

Page 27: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

27

Multiplicity as cardinality and participation constraints

Page 28: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

28

Problems with ER Models

Fan Trap– Where a model represents a relationship between entity types, but

pathway between certain entity occurrences is ambiguous.

Chasm Trap– Where a model suggests the existence of a relationship between

entity types, but pathway does not exist between certain entity occurrences.

Page 29: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

29

An Example of a Fan Trap

Page 30: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

30

Semantic Net of ER Model with Fan Trap

At which branch office does staff number SG37 work?

Page 31: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

31

Restructuring ER model to remove Fan Trap

Page 32: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

32

Semantic Net of Restructured ER Model with Fan Trap Removed

SG37 works at branch B003.

Page 33: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

33

An Example of a Chasm Trap

Page 34: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

34

Semantic Net of ER Model with Chasm Trap

At which branch office is property PA14 available?

Page 35: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

35

ER Model restructured to remove Chasm Trap

Page 36: CS317 File and Database Systems - mercury.pr.erau.edumercury.pr.erau.edu/~siewerts/cs317/documents/... · For Discussion… SA/SD – Focused on Dataflow and Structure 1. SA/SD Included

36

Semantic Net of Restructured ER Model with Chasm Trap Removed