SAN DIEGO SUPERCOMPUTER CENTER Introduction to Database Design July 2006 Ken Nunes sdsc.edu.

Slides:



Advertisements
Similar presentations
BUSINESS DRIVEN TECHNOLOGY Plug-In T4 Designing Database Applications.
Advertisements

SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Accounting System Design
1 Logical Database Design and the Relational Model Modern Database Management.
The Relational Model System Development Life Cycle Normalisation
Systems Development Life Cycle
© 2005 by Prentice Hall 1 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Entity-Relationship Model and Diagrams (continued)
Organizing Data & Information
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Normalization I.
Accounting Databases Chapter 2 The Crossroads of Accounting & IT
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Chapter 3: Data Modeling
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 29 – 04 – 2005.
Week 6 Lecture Normalization
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Web-Enabled Decision Support Systems
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Introduction to Accounting Information Systems
Chapter 1 Overview of Database Concepts Oracle 10g: SQL
RDB/1 An introduction to RDBMS Objectives –To learn about the history and future direction of the SQL standard –To get an overall appreciation of a modern.
SAN DIEGO SUPERCOMPUTER CENTER Introduction to Database Design July 2006 Ken Nunes sdsc.edu.
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Concepts and Terminology Introduction to Database.
CHAPTER 8: MANAGING DATA RESOURCES. File Organization Terms Field: group of characters that represent something Record: group of related fields File:
Lecture 2 An Overview of Relational Database IST 318 – DB Admin.
Normalization. 2 Objectives u Purpose of normalization. u Problems associated with redundant data. u Identification of various types of update anomalies.
Concepts of Relational Databases. Fundamental Concepts Relational data model – A data model representing data in the form of tables Relations – A 2-dimensional.
SALINI SUDESH. Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of.
Chapter 7 1 Database Principles Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that.
MS Access: Creating Relational Databases Instructor: Vicki Weidler Assistant: Joaquin Obieta.
Lecturer: Gareth Jones. How does a relational database organise data? What are the principles of a database management system? What are the principal.
Copyright 2008 McGraw-Hill Ryerson 1 TECHNOLOGY PLUG-IN T5 DESIGNING DATABASE APPLICATIONS.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
Relational Database. Database Management System (DBMS)
DataBase Management System What is DBMS Purpose of DBMS Data Abstraction Data Definition Language Data Manipulation Language Data Models Data Keys Relationships.
Databases Shortfalls of file management systems Structure of a database Database administration Database Management system Hierarchical Databases Network.
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
© 2005 by Prentice Hall 1 The Database Development Process Dr. Emad M. Alsukhni The Database Development Process Dr. Emad M. Alsukhni Modern Database Management.
ITN Table Normalization1 ITN 170 MySQL Database Programming Lecture 3 :Database Analysis and Design (III) Normalization.
In this session, you will learn to: Describe data redundancy Describe the first, second, and third normal forms Describe the Boyce-Codd Normal Form Appreciate.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
9/23/2012ISC329 Isabelle Bichindaritz1 Normalization.
Database Management Supplement 1. 2 I. The Hierarchy of Data Database File (Entity, Table) Record (info for a specific entity, Row) Field (Attribute,
Normalization. 2 u Main objective in developing a logical data model for relational database systems is to create an accurate representation of the data,
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Lection №4 Development of the Relational Databases.
BSA206 Database Management Systems Lecture 2: Introduction to Oracle / Overview of Database Concepts.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
Understand Relational Database Management Systems Software Development Fundamentals LESSON 6.1.
1 © Prentice Hall, 2002 ITD1312 Database Principles Chapter 4B: Logical Design for Relational Systems -- Transforming ER Diagrams into Relations Modern.
Logical Database Design and the Relational Model.
11/10/2009GAK1 Normalization. 11/10/2009GAK2 Learning Objectives Definition of normalization and its purpose in database design Types of normal forms.
Lecture 4: Logical Database Design and the Relational Model 1.
Chapter 5-1. Chapter 5-2 Chapter 5: Organizing and Manipulating the Data in Databases Introduction Normalization Validating the Data in Databases Extracting.
Logical Database Design and Relational Data Model Muhammad Nasir
Microsoft Access CS 110 Fall Entity Relationship Model Entities Entities Principal data object about which information is to be collectedPrincipal.
SLIDE 1IS 257 – Fall 2006 Normalization Normalization theory is based on the observation that relations with certain properties are more effective.
SAN DIEGO SUPERCOMPUTER CENTER Introduction to Database Design July 2005 Ken Nunes sdsc.edu.
Normalization Karolina muszyńska
Chapter 5: Logical Database Design and the Relational Model
Chapter 4 Relational Databases
Database Normalization
Database Design Agenda
Introduction to Database Design
Presentation transcript:

SAN DIEGO SUPERCOMPUTER CENTER Introduction to Database Design July 2006 Ken Nunes sdsc.edu

SAN DIEGO SUPERCOMPUTER CENTER Database Design Agenda Introductions General Design Considerations Entity-Relationship Model Normalization Overview of SQL Star Schemas Additional Information Q&A

SAN DIEGO SUPERCOMPUTER CENTER General Design Considerations Users Application Requirements Legacy Systems/Data

SAN DIEGO SUPERCOMPUTER CENTER Users Who are they? Administrative Scientific Technical Impact Access Controls Interfaces Service levels

SAN DIEGO SUPERCOMPUTER CENTER Application Requirements What kind of database? OnLine Analytical Processing (OLAP) OnLine Transactional Processing (OLTP) Budget Platform / Vendor Workflow? order of operations error handling reporting

SAN DIEGO SUPERCOMPUTER CENTER Legacy Systems/Data What systems are currently in place? Where does the data come from? How is it generated? What format is it in? What is the data used for? Which parts of the system must remain static?

SAN DIEGO SUPERCOMPUTER CENTER Entity - Relationship Model A logical design method which emphasizes simplicity and readability. Basic objects of the model are: Entities Relationships Attributes

SAN DIEGO SUPERCOMPUTER CENTER Entities Data objects detailed by the information in the database. Denoted by rectangles in the model. EmployeeDepartment

SAN DIEGO SUPERCOMPUTER CENTER Attributes Characteristics of entities or relationships. Denoted by ellipses in the model. NameSSN EmployeeDepartment NameBudget

SAN DIEGO SUPERCOMPUTER CENTER Relationships Represent associations between entities. Denoted by diamonds in the model. NameSSN EmployeeDepartment NameBudget works in Start date

SAN DIEGO SUPERCOMPUTER CENTER Relationship Connectivity Constraints on the mapping of the associated entities in the relationship. Denoted by variables between the related entities. Generally, values for connectivity are expressed as “one” or “many” NameSSN EmployeeDepartment NameBudget work 1N Start date

SAN DIEGO SUPERCOMPUTER CENTER Connectivity DepartmentManager has 11 DepartmentProject has N1 EmployeeProject works on NM one-to-one one-to-many many-to-many

SAN DIEGO SUPERCOMPUTER CENTER ER example Retailer wants to create an online webstore. The retailer requires information on: Customers Items Orders

SAN DIEGO SUPERCOMPUTER CENTER Webstore Entities & Attributes Customers - name, credit card, address Items - name, price, inventory Orders - item, quantity, cost, date, status Items Orders inventory priceName itemquantity Customers credit card nameaddress costdatestatus

SAN DIEGO SUPERCOMPUTER CENTER Webstore Relationships Identify the relationships. The orders are recorded each time a customer purchases items, so the customer and order entities are related. Each customer may make several purchases so the relationship is one-to-many Order Customer N 1 purchase

SAN DIEGO SUPERCOMPUTER CENTER Webstore Relationships Identify the relationships. The order consists of the items a customer purchases but each item can be found in multiple orders. Since a customer can purchase multiple items and make multiple orders the relationship is many to many. OrderItem consists NM

SAN DIEGO SUPERCOMPUTER CENTER Webstore ER Diagram Orders Customers Items purchase consists N N 1 M itemquantitycostnameprice credit cardnameaddress inventory status date

SAN DIEGO SUPERCOMPUTER CENTER Logical Design to Physical Design Creating relational SQL schemas from entity- relationship models. Transform each entity into a table with the key and its attributes. Transform each relationship as either a relationship table (many-to-many) or a “foreign key” (one-to-many and many-to-many).

SAN DIEGO SUPERCOMPUTER CENTER Entity tables Transform each entity into a table with a key and its attributes. NameSSN Employee create table employee (emp_no number, name varchar2(256), ssn number, primary key (emp_no));

SAN DIEGO SUPERCOMPUTER CENTER Foreign Keys Transform each one-to-one or one-to-many relationship as a “foreign key”. Foreign key is a reference in the child (many) table to the primary key of the parent (one) table. create table employee (emp_no number, dept_no number, name varchar2(256), ssn number, primary key (emp_no), foreign key (dept_no) references department); Employee Department has 1 N create table department (dept_no number, name varchar2(50), primary key (dept_no));

SAN DIEGO SUPERCOMPUTER CENTER Foreign Key Department Employee Accounting has 1 employee: Brian Burnett Human Resources has 2 employees: Nora Edwards Ben Smith IT has 3 employees: Ajay Patel John O’Leary Julia Lenin

SAN DIEGO SUPERCOMPUTER CENTER Many-to-Many tables Transform each many-to-many relationship as a table. The relationship table will contain the foreign keys to the related entities as well as any relationship attributes. create table project_employee_details (proj_no number, emp_no number, start_date date, primary key (proj_no, emp_no), foreign key (proj_no) references project foreign key (emp_no) references employee); Employee Project has N M Start date

SAN DIEGO SUPERCOMPUTER CENTER Many-to-Many tables Project Employee Project_employee_details Employee Audit has 1 employee: Brian Burnett Budget has 2 employees: Julia Lenin Nora Edwards Intranet has 3 employees: Julia Lenin John O’Leary Ajay Patel

SAN DIEGO SUPERCOMPUTER CENTER Normalization A logical design method which minimizes data redundancy and reduces design flaws. Consists of applying various “normal” forms to the database design. The normal forms break down large tables into smaller subsets.

SAN DIEGO SUPERCOMPUTER CENTER First Normal Form (1NF) Each attribute must be atomic No repeating columns within a row. No multi-valued columns. 1NF simplifies attributes Queries become easier.

SAN DIEGO SUPERCOMPUTER CENTER 1NF Employee (unnormalized) Employee (1NF)

SAN DIEGO SUPERCOMPUTER CENTER Second Normal Form (2NF) Each attribute must be functionally dependent on the primary key. Functional dependence - the property of one or more attributes that uniquely determines the value of other attributes. Any non-dependent attributes are moved into a smaller (subset) table. 2NF improves data integrity. Prevents update, insert, and delete anomalies.

SAN DIEGO SUPERCOMPUTER CENTER Functional Dependence Name, dept_no, and dept_name are functionally dependent on emp_no. (emp_no -> name, dept_no, dept_name) Skills is not functionally dependent on emp_no since it is not unique to each emp_no. Employee (1NF)

SAN DIEGO SUPERCOMPUTER CENTER 2NF Employee (1NF) Employee (2NF)Skills (2NF)

SAN DIEGO SUPERCOMPUTER CENTER Data Integrity Insert Anomaly - adding null values. eg, inserting a new department does not require the primary key of emp_no to be added. Update Anomaly - multiple updates for a single name change, causes performance degradation. eg, changing IT dept_name to IS Delete Anomaly - deleting wanted information. eg, deleting the IT department removes employee Barbara Jones from the database Employee (1NF)

SAN DIEGO SUPERCOMPUTER CENTER Third Normal Form (3NF) Remove transitive dependencies. Transitive dependence - two separate entities exist within one table. Any transitive dependencies are moved into a smaller (subset) table. 3NF further improves data integrity. Prevents update, insert, and delete anomalies.

SAN DIEGO SUPERCOMPUTER CENTER Transitive Dependence Dept_no and dept_name are functionally dependent on emp_no however, department can be considered a separate entity. Employee (2NF)

SAN DIEGO SUPERCOMPUTER CENTER 3NF Employee (2NF) Employee (3NF) Department (3NF)

SAN DIEGO SUPERCOMPUTER CENTER Other Normal Forms Boyce-Codd Normal Form (BCNF) Strengthens 3NF by requiring the keys in the functional dependencies to be superkeys (a column or columns that uniquely identify a row) Fourth Normal Form (4NF) Eliminate trivial multivalued dependencies. Fifth Normal Form (5NF) Eliminate dependencies not determined by keys.

SAN DIEGO SUPERCOMPUTER CENTER Normalizing our webstore (1NF) customers items item_idnamepriceinventory 34sweater red sweater blue t-shirt jeans755 81jacket1759 cust_idnameaddresscredit_card_numcredit_card_type 45Mike Speedy123 A St.45154visa 45Mike Speedy123 A St.32499mastercard 45Mike Speedy123 A St.12834discover 78Frank Newmon2 Main St.45698visa 102Joe Powers343 Blue Blvd.94065mastercard 102Joe Powers343 Blue Blvd.10532discover orders order_idcust_iditem_idquantitycost datestatus /306shipped /306shipped /306shipped /5/06refunded /10/06shipped /10/06shipped

SAN DIEGO SUPERCOMPUTER CENTER Normalizing our webstore (2NF & 3NF) customerscredit_cards cust_idnameaddress 45Mike Speedy123 A St. 78Frank Newmon2 Main St. 102Joe Powers343 Blue Blvd. cust_idnumtype visa mastercard discover visa mastercard discover

SAN DIEGO SUPERCOMPUTER CENTER Normalizing our webstore (2NF & 3NF) order details order_iditem_idquantitycost items item_idnamepriceinventory 34sweater red sweater blue t-shirt jeans755 81jacket1759 order_id cust_iddatestatus /306shipped /5/06refunded /10/06shipped orders

SAN DIEGO SUPERCOMPUTER CENTER Revisit webstore ER diagram Orders Customers Items purchase have N N 1 1 nameprice name address inventory consists N M Credit card card numbercard type status date Order details consists N 1 quantity cost

SAN DIEGO SUPERCOMPUTER CENTER Structured Query Language SQL is the standard language for data definition and data manipulation for relational database systems. Nonprocedural Universal

SAN DIEGO SUPERCOMPUTER CENTER Data Definition Language The aspect of SQL that defines and manipulates objects in a database. create tables alter tables drop tables create views