Database Design
The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number of ordered formal processes with known inputs and expected outputs Objectives 1. derive relationships 2. evolve to meet user requirements 3. Do it right the first time! Database Design
· Reduce data redundancy. · Provide stable data structures that can be readily changed with changing user requirements. · Allow users to make ad hoc requests for data. · Maintain complex relationships between data elements. · Support a large variety of decision needs Database Design Goals
data availability data reliability data currency data consistency data flexibility data efficiency Verify these criteria are satisfied via technical review Database Design
3 types of data objects:3 types of data objects: –Entities –Attributes –Relationships ENTITIES: Are persons, places, or things about which data is to be, or is, gatheredENTITIES: Are persons, places, or things about which data is to be, or is, gathered ATTRIBUTES : Are the properties of entities. Examples are Names, Tax Numbers, Age, StatusATTRIBUTES : Are the properties of entities. Examples are Names, Tax Numbers, Age, Status RELATIONSHIPS : Describe how entities relate to each other eg Customers BUY ProductsRELATIONSHIPS : Describe how entities relate to each other eg Customers BUY Products – Persons WORK_ON Jobs Logical Data Modeling
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...
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 Design
Physical Level Design Final Information Level Design Functional Requirements Information Level Design Processes Physical Constraints Final Database Structure Other matters Domains, Nulls, Derived Data, Encoded Data. Data Base Model Database Design
2 entities can be related as : One to One : (1 : 1) The interpretation of this is that an occurrence of an entity ‘A’ can relate to ONE and ONLY ONE occurrence of entity ‘B’, and an occurrence of entity ‘B’ can relate to ONE and ONLY ONE occurrence of entity ‘A’ One to Many : (1: N) The interpretation is that ONE occurrence of entity ‘A’ can relate to ONE or MORE occurrences of entity ‘B’, but an occurrence of entity ‘B’ can relate to ONE ONLY occurrence of entity ‘A’ Logical Data Modeling
Many to Many (N : N) - a common business relationship The interpretation is that ONE or MORE occurrences of entity ‘A’ can relate to ONE or MORE occurrences of entity ‘B’ and ONE or MORE occurrences of entity ‘B’ can relate to ONE or MORE occurrences of entity ‘A’ Logical Data Modeling
Type Shown As Example Type Shown As Example One to One 1:1 Book -----> Title One to Many 1:N Publisher ---- >Books Many to Many N:N Books Authors Entity Relationships
Normalization Normalization is the process of organizing data in a database. This includes creating tables and establishing relationships between those tables according to rules designed both to protect the data and to make the database more flexible by eliminating two factors: redundancy and inconsistent dependency.
Unnormalized Table Student# Advisor Adv-Room Class1 Class2 Class Jones Jones Smith Smith
First Normal Form Eliminate repeating groups in individual tables.Eliminate repeating groups in individual tables. Create a separate table for each set of related data.Create a separate table for each set of related data. Identify each set of related data with a primary key.Identify each set of related data with a primary key.
No Repeating Groups Student# Advisor Adv-Room Class# Student# Advisor Adv-Room Class# Jones Jones Jones Jones Jones Jones Smith Smith Smith Smith Smith Smith
Second Normal Form Create separate tables for sets of values that apply to multiple records.Create separate tables for sets of values that apply to multiple records. Relate these tables with a foreign key.Relate these tables with a foreign key.
Eliminate Redundant Data The following two tables demonstrate second normal form: The following two tables demonstrate second normal form: Students: Student# Advisor Adv-Room Students: Student# Advisor Adv-Room Jones Jones Smith Smith 216 Registration: Student# Class# Registration: Student# Class#
Third Normal Form Eliminate fields that do not depend on the key.Eliminate fields that do not depend on the key.
Eliminate data not dependant on key Students: Student# Advisor Jones 1022 Jones 4123 Smith 4123 Smith Faculty: Name Room Dept Jones Jones Smith Smith
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 Design