basic database analysis(database)

45
Lecture 3: Basic Database Analysis ISOM3260, Spring 2014

Upload: welcometofacebook

Post on 28-Jan-2015

129 views

Category:

Engineering


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Basic database analysis(database)

Lecture 3: Basic Database Analysis

ISOM3260, Spring 2014

Page 2: Basic database analysis(database)

2

Where we are now• Database environment

– introduction to database• Database development process

– steps to develop a database• Conceptual data modeling

– entity-relationship (ER) diagram; enhanced ER• Logical database design

– transforming ER diagram into relations; normalization• Physical database design

– technical specifications of the database• Database implementation

– Structured Query Language (SQL), Advanced SQL• Advanced topics

– data and database administration

Page 3: Basic database analysis(database)

3

Database development activities during SDLC

Top-downanalysis

Page 4: Basic database analysis(database)

4

Basic Database Analysis

• Business Rules• E-R Model• Entities• Attributes• Relationships

Page 5: Basic database analysis(database)

5

Business Rules

• Statements that define or constrain some aspect of the business

• Include– names and definitions of entity types, attributes, and

relationships– constraints on above data objects

• Expressed in terms familiar to end users– e.g. Every student in the university must have a faculty

advisor• Automated through DBMS software• Some business rules cannot be represented in E-R

diagram; instead they are stated in natural language

Page 6: Basic database analysis(database)

6

Figure 2-1: Sample E-R Diagram

Page 7: Basic database analysis(database)

7

Figure 2-2: Basic E-R Notation

Entity symbols

Relationship symbols

Attribute symbols

A special entity that is also a relationship

Page 8: Basic database analysis(database)

8

E-R Model Constructs• Entity - person, place, object, event,

concept• Entity Type versus Entity Instance

Page 9: Basic database analysis(database)

9

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)

Page 10: Basic database analysis(database)

10

Inappropriate entities

System user System output

Appropriate entities

Figure 2-4

Page 11: Basic database analysis(database)

11

Strong vs. Weak Entity Type

• Strong entity – exists 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

Page 12: Basic database analysis(database)

12

Figure 2-5: Strong and weak entities

Page 13: Basic database analysis(database)

13

Attributes

• Attribute– property or characteristic of an entity type

• Classifications of attributes– Simple versus Composite Attribute– Single-Valued versus Multivalued Attribute– Stored versus Derived Attributes– Identifier Attributes

Page 14: Basic database analysis(database)

14

Figure 2-7: A composite attribute

An attribute broken into component parts

Page 15: Basic database analysis(database)

15

Figure 2-8: Entity with a multivalued attribute (Skill) and derived attribute (Years_Employed)

Derived from date employed and current date

Multivalued: an employee can have more than one skill

Page 16: Basic database analysis(database)

16

Identifier Attribute

• 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

Page 17: Basic database analysis(database)

17

Characteristics of Identifiers

• Will not change in value• Will not be null• No intelligent identifiers

– e.g. containing locations that might change• Substitute new, simple keys for long, composite keys

– e.g. Game_Number instead of Home_Team and Visiting_Team

Page 18: Basic database analysis(database)

18

Figure 2-9a: Simple key attribute

The key is underlined

Page 19: Basic database analysis(database)

19

Figure 2-9b: Composite key attribute

The key is composed of two subparts

Page 20: Basic database analysis(database)

20

Relationships

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

and lines between entity types…the instance is between specific entity instances

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

association between the entities in the relationship

Page 21: Basic database analysis(database)

21

Figure 2-10a: Relationship type (Completes)

Figure 2-10b: Relationship instances

Page 22: Basic database analysis(database)

22

Figure 2-11a: A binary relationship with an attribute

Here, the Date_Completed attribute refers to the employee’s completion of a course…it is an attribute of the relationship

Page 23: Basic database analysis(database)

23

Associative Entities• It’s an entity – it has attributes• AND it’s a relationship – it links entities together

• When should a relationship with attributes instead be an

associative entity? – all relationships for the associative entity should be many– the associative entity could have meaning independent of the other

entities– the associative entity preferably has a unique identifier, and should

also have other attributes– the associative entity may be participating in other relationships other

than the entities of the associated relationship– ternary relationships should be converted to associative entities

Page 24: Basic database analysis(database)

24

Figure 2-11b: An associative entity (CERTIFICATE)

Associative entity involves a rectangle with a diamond inside.Note that the many-to-many cardinality symbols face toward the associative entity and not toward the other entities.

Page 25: Basic database analysis(database)

25

Degree of a Relationship

• Degree of a Relationship is the number of entity types that participate in it– Unary Relationship (degree 1)– Binary Relationship (degree 2)– Ternary Relationship (degree 3)

Page 26: Basic database analysis(database)

26

Figure 2-2: Degree of relationships

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

Page 27: Basic database analysis(database)

27

Figure 2-12a: Unary relationships

Page 28: Basic database analysis(database)

28

Representing a bill-of -materials structure

Figure 2-13a: A unary relationship with an attribute. This has a many-to-many relationship

Page 29: Basic database analysis(database)

29

(b) Two instances

Page 30: Basic database analysis(database)

30

Figure 2-13c: An associative entity – bill of materials structure

Page 31: Basic database analysis(database)

31

Figure 2-12b: Binary relationships

Page 32: Basic database analysis(database)

32

Figure 2-12c: Ternary relationships

Page 33: Basic database analysis(database)

33

Figure 2-14: Ternary relationships as an associative entity

Page 34: Basic database analysis(database)

34

Cardinality of Relationships

• One–to–One– each entity instance in the relationship will have

exactly one related entity instance• One–to–Many

– an entity instance on one side of the relationship can have many related entity instances, but an entity instance on the other side will have a maximum of one related entity instance

• Many–to–Many– entity instances on both sides of the relationship can

have many related entity instances on the other side

Page 35: Basic database analysis(database)

35

Cardinality Constraints

• Cardinality 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 optional– if one or more, then mandatory

• Maximum Cardinality– the maximum number

Page 36: Basic database analysis(database)

36

Figure 2-2: Cardinality

Page 37: Basic database analysis(database)

37

Figure 2-16a: Basic relationship with only maximum cardinalities showing

Figure 2-17a: Mandatory cardinalities

Page 38: Basic database analysis(database)

38

Figure 2-17b: One optional, one mandatory cardinality

Page 39: Basic database analysis(database)

39

Figure 2-17c: Optional cardinalities

Page 40: Basic database analysis(database)

40

Figure 2-18: Cardinality constraints in a ternary relationship

Page 41: Basic database analysis(database)

41

More about Relationships

• Modeling Time-Dependent Data– Time Stamps (such as date and time)

• Multiple Relationships– more than one relationship between the same

entity types

Page 42: Basic database analysis(database)

42

Figure 2-19: Example of time stamping

Page 43: Basic database analysis(database)

43

Examples of multiple relationships – entities can be related to one another in more than one way

Figure 2-21a: Employees and departments

Page 44: Basic database analysis(database)

44

Figure 2-21b: Professors and courses (fixed upon constraint)

Maximum cardinality constraint is 4

Page 45: Basic database analysis(database)

45

Figure 2-22: E-R diagram for Pine Valley Furniture