database design. the process of developing database structures from user requirements for data a...

20
Database Design Database Design

Upload: shon-sullivan

Post on 31-Dec-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

Database DesignDatabase Design

Page 2: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

• The process of developing database structures from user requirements for data

• a structured methodology

Structured Methodology - a number of ordered formalprocesses with known inputs and expected outputs

Objectives 1. derive relationships2. evolve to meet user requirements3. Do it right the first time!

Database DesignDatabase Design

Page 3: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

· Reduce data redundancy.Reduce data redundancy.

· Provide stable data structures that can be Provide stable data structures that can be readily changed with changing user readily changed with changing user requirements.requirements.

· Allow users to make ad hoc requests for Allow users to make ad hoc requests for data.data.

· Maintain complex relationships between Maintain complex relationships between data elements.data elements.

· Support a large variety of decision needsSupport a large variety of decision needs

Database Design GoalsDatabase Design Goals

Page 4: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

• data availability

• data reliability

• data currency

• data consistency

• data flexibility

• data efficiency

Verify these criteria are satisfied via technical review

Database DesignDatabase Design

Page 5: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

• 3 types of data objects:3 types of data objects:– EntitiesEntities

– AttributesAttributes

– RelationshipsRelationships

• ENTITIESENTITIES: : Are persons, places, or things about which data is to be, Are persons, places, or things about which data is to be, or is, gatheredor is, gathered

• ATTRIBUTESATTRIBUTES : : Are the properties of entities.Are the properties of entities.Examples are Names, Tax Numbers, Age, StatusExamples are Names, Tax Numbers, Age, Status

• RELATIONSHIPSRELATIONSHIPS : : Describe how entities relate to each otherDescribe how entities relate to each other eg Customers BUY Productseg Customers BUY Products

– Persons WORK_ON JobsPersons WORK_ON Jobs

Logical Data ModelingLogical Data Modeling

Page 6: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

•Are persons, objects or events about which information is, or will be, recorded in the Database

•The designation of a ‘thing’ about which data is to be collected, stored or processed.

•Many of these Entities can be identified with Business Activities (e.g. suppliers, purchase orders, customer)

Entities...Entities...

Page 7: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

Designing a database involves choosing:

1. The tables that belong in the database.What are the entities?

2. The columns that belong in each table.What are the properties?

3. How tables and columns interact with each other.What do they have in common?

3 Steps in Design3 Steps in Design

Page 8: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

PhysicalLevel Design

Final InformationLevel Design

FunctionalRequirements

Information LevelDesign Processes

PhysicalConstraints

Final DatabaseStructure

Other mattersDomains, Nulls, Derived Data,Encoded Data.

Data Base Model

Database DesignDatabase Design

Page 9: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

2 entities can be related as :2 entities can be related as :

One to One : (1 : 1)One to One : (1 : 1)

The interpretation of this is that an occurrence of an The interpretation of this is that an occurrence of an entity ‘A’ can relate to ONE and ONLY ONE occurrence entity ‘A’ can relate to ONE and ONLY ONE occurrence of entity ‘B’, and an occurrence of entity ‘B’ can relate of entity ‘B’, and an occurrence of entity ‘B’ can relate to ONE and ONLY ONE occurrence of entity ‘A’to ONE and ONLY ONE occurrence of entity ‘A’

One to Many : (1: N) One to Many : (1: N)

The interpretation is that ONE occurrence of entity ‘A’ The interpretation is that ONE occurrence of entity ‘A’ can relate to ONE or MORE occurrences of entity ‘B’, can relate to ONE or MORE occurrences of entity ‘B’, but an occurrence of entity ‘B’ can relate to ONE but an occurrence of entity ‘B’ can relate to ONE ONLY occurrence of entity ‘A’ONLY occurrence of entity ‘A’

Logical Data ModelingLogical Data Modeling

Page 10: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

Many to Many (N : N)Many to Many (N : N) - a common business - a common business relationshiprelationship

The interpretation is that ONE or MORE The interpretation is that ONE or MORE occurrences of entity ‘A’ can relate to ONE or occurrences of entity ‘A’ can relate to ONE or MORE occurrences of entity ‘B’ and ONE or MORE occurrences of entity ‘B’ and ONE or MORE occurrences of entity ‘B’ can relate to MORE occurrences of entity ‘B’ can relate to ONE or MORE occurrences of entity ‘A’ONE or MORE occurrences of entity ‘A’

Logical Data ModelingLogical Data Modeling

Page 11: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

Type Shown As Example Type Shown As Example

One to OneOne to One 1:1 1:1 Book -----> TitleBook -----> Title

One to ManyOne to Many 1:N 1:N Publisher ----Publisher ---->Books>Books

Many to ManyMany to Many N:NN:N Books <---Books <--->Authors>Authors

Entity RelationshipsEntity Relationships

Page 12: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

NormalizationNormalization

Normalization is the process of organizing Normalization is the process of organizing data in a database. This includes data in a database. This includes creating tables and establishing creating tables and establishing relationships between those tables relationships between those tables according to rules designed both to according to rules designed both to protect the data and to make the protect the data and to make the database more flexible by database more flexible by eliminating eliminating two factors: redundancy and two factors: redundancy and inconsistent dependency. inconsistent dependency.

Page 13: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

Unnormalized TableUnnormalized Table

Student# Advisor Adv-Room Class1 Class2 Class3Student# Advisor Adv-Room Class1 Class2 Class3

--------------------------------------------------------------------------------------------------------------

1022 Jones 412 101-07 143-01 159-021022 Jones 412 101-07 143-01 159-02

4123 Smith 216 201-01 211-02 214-014123 Smith 216 201-01 211-02 214-01

Page 14: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

First Normal FormFirst Normal Form

• Eliminate repeating groups in Eliminate repeating groups in individual tables. individual tables.

• Create a separate table for each set Create a separate table for each set of related data. of related data.

• Identify each set of related data Identify each set of related data with a primary key. with a primary key.

Page 15: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

No Repeating GroupsNo Repeating Groups

Student# Advisor Adv-Room Class#Student# Advisor Adv-Room Class#

------------------------------------------------------------------------------

1022 Jones 412 101-071022 Jones 412 101-07

1022 Jones 412 143-011022 Jones 412 143-01

1022 Jones 412 159-021022 Jones 412 159-02

4123 Smith 216 201-014123 Smith 216 201-01

4123 Smith 216 211-024123 Smith 216 211-02

4123 Smith 216 214-01 4123 Smith 216 214-01

Page 16: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

Second Normal FormSecond Normal Form

• Create separate tables for sets of Create separate tables for sets of values that apply to multiple values that apply to multiple records. records.

• Relate these tables with a foreign Relate these tables with a foreign key. key.

Page 17: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

Eliminate Redundant DataEliminate Redundant Data

The following two tables demonstrate second normal form:The following two tables demonstrate second normal form:

Students: Student# Advisor Adv-RoomStudents: Student# Advisor Adv-Room ------------------------------------------------------------ 1022 Jones 4121022 Jones 412 4123 Smith 2164123 Smith 216

Registration: Student# Class#Registration: Student# Class# ------------------------------------ 1022 101-071022 101-07 1022 143-011022 143-01 1022 159-021022 159-02 4123 201-014123 201-01 4123 211-024123 211-02 4123 214-01 4123 214-01

Page 18: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

Third Normal FormThird Normal Form

• Eliminate fields that do not depend Eliminate fields that do not depend on the key. on the key.

Page 19: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

Eliminate data not Eliminate data not dependant on keydependant on keyStudents: Students: Student# AdvisorStudent# Advisor

--------------------------------------

1022 Jones1022 Jones

4123 Smith4123 Smith

Faculty: Faculty: Name Room DeptName Room Dept

----------------------------------------

Jones 412 42Jones 412 42

Smith 216 42 Smith 216 42

Page 20: Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number

A database which will:

• Accurately reflect the ‘real world’ data in all required aspects

• Be responsive to Management information demands

• Reflect Business Rules and Controls

• Be capable of modification to meet changes in Management needs

• Be an asset to the Organization/Enterprise

End Product of Data Base End Product of Data Base DesignDesign