BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

30
BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design

Transcript of BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

Page 1: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

BIS310: Week 7 BIS310: Structured Analysis and Design

Data Modelingand

Database Design

Page 2: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Overview of Database Design

• Capture Users’ “Views” of data– Forms, Screens, Reports

• Data Modeling (entity-based ERD)– Add keys, attributes, relationships (key-based, and

fully-described ERD)

• Consolidate data models – One big ERD• Determine Database Schema (database

design)

Page 3: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Data Modeling

• Data modeling is a technique for organizing and documenting a system’s DATA. Data modeling is sometimes called database modeling because a data model is usually implemented as a database.

Page 4: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Page 5: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

System Concepts

Systems thinking is the application of formal systems theory and concepts to systems problem solving.

An ERD depicts data in terms of the entities and relationships described by the data.

Page 6: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Entities

An entity is something about which we want to store data.

An entity is a class of persons, places, objects, events, or concepts about which we need to capture and store data.

An entity instance is a single occurrence of an entity.

Page 7: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Attributes

• An attribute is a descriptive property or characteristic of an entity. Synonyms include element, property, and field

Page 8: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Attributes - Identification

Every entity must have an identifier or key.– An key is an attribute, or a group of attributes,

which assumes a unique value for each entity instance. It is sometimes called an identifier.

Sometimes more than one attribute is required to uniquely identify an instance of an entity.– A group of attributes that uniquely identifies an

instance of an entity is called a concatenated key. Synonyms include composite key and compound key.

Page 9: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Relationships

A relationship is a natural business association that exists between one or more entities. The relationship may represent an event that links the entities, or merely a logical affinity that exists between the entities.

A connecting line between two entities on an ERD represents a relationship.

A verb phrase describes the relationship.– All relationships are implicitly bidirectional, meaning

that they can interpreted in both directions.

Page 10: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Page 11: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Cardinality

Each relationship on an ERD also depicts the complexity or degree of each relationship, and this is called cardinality.– Cardinality defines the minimum and maximum

number of occurrences of one entity for a single occurrence of the related entity. Because all relationships are bi-directional, cardinality must be defined in both directions for every relationship.

Page 12: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

C a r d i n a l i t yI n t e r p r e t a t i o n

M i n i m u mI n s t a n c e s

M a x i m u mI n s t a n c e s

G r a p h i c N o t a t i o n

E x a c t l y o n e 1 1

Z e r o o r o n e 0 1

O n e o r m o r e 1 m a n y ( > 1 )

Z e r o , o n e , o r m o r e 0 m a n y ( > 1 )

M o r e t h a n o n e > 1 > 1

F i g u r e 5 . 3

Page 13: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Foreign Keys

A relationship implies that instances of one entity are related to instances of another entity.

To be able to identify those instances for any given entity, the primary key of one entity must be migrated into the other entity as a foreign key.– A foreign key is a primary key of one entity that is contributed

to (duplicated in) another entity for the purpose of identifying instances of a relationship. A foreign key (always in a child entity) always matches the primary key (in a parent entity).

Page 14: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Page 15: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

(a)

(b)

Page 16: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Data Modeling During Systems Analysis

1 A key-based data model will be drawn first. 2 A fully attributed data model will be

constructed along with the process of analysis and design.

– Each attribute is defined in the repository with data types, domains, and defaults.

Page 17: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

How to Construct Data Models

1st Step - Entity Discovery The first task is to discover those fundamental entities in the

system. There are several techniques that may be used to identify entities.

During interviews or JAD sessions with system owners and users, pay attention to key words in their discussion.

During interviews or JAD sessions, specifically ask the system owners and users to identify things about which they would like to capture, store, and produce information.

Study existing forms and files. Some CASE tools can reverse engineer existing files and

databases into physical data models.

Page 18: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

How to Construct Data Models

1st Step - Entity Discovery An entity has multiple instances Entities should be named with nouns that describe the person,

event, place, or intangible thing about which we want to store data. Define each entity in business terms.

Page 19: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

How to Construct Data Models

2nd Step - The Context Data Model The second task in data modeling is to construct the context data

model. The context data model includes the fundamental or independent entities that were previously discovered.

• An independent entity is one which exists regardless of the existence of any other entity. Its primary key contain no attributes that would make it dependent on the existence of another entity.

• Independent entities are almost always the first entities discovered in your conversations with the users.

Relationships should be named with verb phrases that, when combined with the entity names, form simple business sentences or assertions.

• If only one-way naming is used, always name the relationship from parent-to-child.

Page 20: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Page 21: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

How to Construct Data Models

3rd Step - The Key-Based Data Model The third task is to identify the keys of each entity. If you cannot define keys for an entity, it may be that the entity

doesn’t really exist—that is, multiple occurrences of the so-called entity do not exist.

Page 22: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Page 23: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

How to Construct Data Models

4th Step - Generalized Hierarchies At this time, it would be useful to identify any generalization

hierarchies in a business problem.

5th Step - The Fully Attributed Data Model The fifth task is to identify the remaining data attributes.

6th Step - The Fully Described Model The last task is to fully describe the data model. Most CASE tools provide extensive facilities for describing the

data types, domains, and defaults for all attributes to the repository.

Page 24: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Conventional Files Versus the Database

• Files are collections of similar records.

• Databases are collections of interrelated files.

– Discuss advantages and disadvantages of each

– Compare and Contrast

Page 25: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Databases

• A database management system (DBMS) is specialized computer software available from computer vendors that is used to create, access, control, and manage the database.

Page 26: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

A legacy file-based

information system

(built in-house)

File

FileInformation

System

(built in-house)

Information System

(built in-house)

Operational Database

File

File

Information System

(built in-house)

A legacy file-based

information system

(purchased)

File

File

File

Information System

(purchased)

Operational Database

Data Warehouse

End-User Tools

End-User Applications

Personal DB

Work-Group Database

Users and Programmers

Users and Programmers

Users and Programmers

Users and Programmers

Users

End-User Work Group

Page 27: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

A Simple Logical Data Model

sells sold onOrdered Product

Customer Order Productplaces

Page 28: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7Customers TableCustomer Number Customer Name Customer

Balance…

10112 Luck Star 1455.7710113 Pemrose 12.1410114 Hartman 0.0010117 K-Jack Industries - 20.00

OrdersTableOrderNumber

Customer Number(foreign key)

A633 10112A634 10114A635 10112

Ordered Products TableOrderNumber(foreignkey)

Product Number(foreign key)

QuantityOrdered

A633 77F02 1A633 77B12 500A634 77B13 100A634 77F01 5A635 77B12 300A635 77B15 15

Products TableProduct Number Product Description Quantity

in Stock…

77B12 Widget 800077B13 Widget 077B15 Widget 5277F01 Gadget 2077F02 Gadget 2

Page 29: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

The Database Schema

– Data type. Each DBMS supports different data types, and terms for those data types.

– Size of the Field. Different DBMSs express precision of real numbers differently.

– Required or NOT Required. Must the field have a value before the record can be committed to storage?

– Domains. Many DBMSs can automatically edit data to ensure that fields contain legal data.

– Default. Many DBMSs allow a default value to be automatically set in the event that a user or programmer submits a record without a value.

– Referential Integrity. An integrity constraint specifying that the value (or existence) of an attribute in one relation depends on the value (or existence) of the same attribute in another relation

Page 30: BIS310: Week 7 BIS310: Structured Analysis and Design Data Modeling and Database Design.

06.5.18

BIS310: Week 7

Other Considerations

• Denormalization

• Choices of storage formats

• File organizations

• Backup/Recovery

• Security of Data