1 A Guide to MySQL 2 Database Design Fundamentals.

Slides:



Advertisements
Similar presentations
Database Design: Normalization J.G. Zheng June 29 th 2005 DB Chapter 4.
Advertisements

5 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
BUSINESS DRIVEN TECHNOLOGY Plug-In T4 Designing Database Applications.
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
Concepts of Database Management Seventh Edition Chapter 6 Database Design : ERD Model.
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
Modeling the Data: Conceptual and Logical Data Modeling
Concepts of Database Management Sixth Edition
Fundamentals, Design, and Implementation, 9/e Chapter 4 The Relational Model and Normalization.
Concepts of Database Management Sixth Edition
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Concepts of Database Management Sixth Edition
1 6 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 6 Database Design 2: Design Methodology.
1 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 5 Database Design: Normalization.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Database Design Chapter 2. Goal of all Information Systems  To add value –Reduce costs –Increase sales or revenue –Provide a competitive advantage.
Concepts of Database Management Seventh Edition Chapter 1 Introduction to Database Management.
Concepts of Database Management Seventh Edition
1 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 5 Database Design 1: Normalization.
Part ( PartNum, Description, OnHand, Class, Warehouse, Price,
APPENDIX C DESIGNING DATABASES
Entity-Relationship Design
Chapter 3 The Relational Model and Normalization
Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 29 – 04 – 2005.
Chapter 5 Normalization of Database Tables
DBSQL 4-1 Copyright © Genetic Computer School 2009 Chapter 4 Database Design.
Concepts of Database Management Seventh Edition
Concepts of Database Management Seventh Edition Chapter 5 Database Design 1: Normalization.
Web-Enabled Decision Support Systems
A Guide to SQL, Eighth Edition Chapter Two Database Design Fundamentals.
Chapter 1 Overview of Database Concepts Oracle 10g: SQL
Concepts of Database Management, Fifth Edition Chapter 1: Introduction to Database Management.
Concepts and Terminology Introduction to Database.
Concepts of Database Management Seventh Edition Chapter 4 Keys and Relationship.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Fundamentals, Design, and Implementation, 9/e. Database Processing: Fundamentals, Design and Implementation, 9/e by David M. KroenkeChapter 4/2 Copyright.
Concepts of Database Management Sixth Edition Chapter 5 Database Design 1: Normalization.
Concepts of Database Management, Fifth Edition
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 6 Normalization of Database Tables.
1 A Guide to MySQL 2 Database Design Fundamentals.
Copyright 2008 McGraw-Hill Ryerson 1 TECHNOLOGY PLUG-IN T5 DESIGNING DATABASE APPLICATIONS.
McGraw-Hill/Irwin © 2008 The McGraw-Hill Companies, All Rights Reserved Plug-In T5: Designing Database Applications Business Driven Technology.
Concepts of Database Management Seventh Edition
Concepts of Database Management Sixth Edition Chapter 6 Database Design 2: Design Method.
1 CSE 2337 Introduction to Data Management Textbook: Chapter 1.
Concepts of Database Management, Fifth Edition Chapter 6: Database Design 2: Design Methodology.
Description and exemplification of entity-relationship modelling.
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.
Concepts of Database Management Seventh Edition Chapter 1 Introduction to Database Management.
Information Access Mgt09/12/971 Entity-Relationship Design Information Level Design.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Concepts of Database Management Seventh Edition Chapter 5 Database Design 1: Normalization.
Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin APPENDIX C DESIGNING DATABASES APPENDIX C DESIGNING DATABASES.
1 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Chapter 6 Database Design 2: Design Methodology Spring 2006.
Concepts of Database Management, Fifth Edition Chapter 6: Database Design 2: Design Methodology.
Concepts of Database Management Seventh Edition Chapter 4 Keys and Relationship.
Microsoft Access 2010 Chapter 11 Database Design.
Southern Methodist University CSE CSE 2337 Introduction to Data Management Chapter 5 Part II.
Normalization ACSC 425 Database Management Systems.
Logical Database Design and Relational Data Model Muhammad Nasir
SLIDE 1IS 257 – Fall 2006 Normalization Normalization theory is based on the observation that relations with certain properties are more effective.
A Guide to SQL, Eighth Edition
Database, tables and normal forms
Chapter 11 Database Design
Concepts of Database Management Eighth Edition
Normalization – Part II
Chapter 14 Normalization Pearson Education © 2009.
Shelly Cashman: Microsoft Access 2016
Presentation transcript:

1 A Guide to MySQL 2 Database Design Fundamentals

Objectives A Guide to MySQL 2  Understand the terms entity, attribute, and relationship  Understand the terms relation and relational database  Understand functional dependence and be able to identify when one column is functionally dependent on another  Understand the term primary key and identify primary keys in tables

Objectives (continued) A Guide to MySQL 3  Design a database to satisfy a set of requirements  Convert an unnormalized relation to first normal form  Convert tables from first normal form to second normal form  Convert tables from second normal form to third normal form  Create an entity-relationship diagram to represent the design of a database

Introduction A Guide to MySQL 4  Database design: process of determining the particular tables and columns that will comprise a database  Must understand database concepts  Process of normalization  Don’t be afraid to make mistakes as long as you are willing to make changes.

Relational Database A Guide to MySQL 5  A collection of tables  A relational database is a collection of data items organized as a set of formally-described tables from which data can be accessed or reassembled in many different ways without having to reorganize the database tables.  The relational database was invented by E. F. Codd at IBM in 1970.

A Guide to MySQL 6 Relational Database (continued)

A Guide to MySQL 7

8

Entities, Attributes, and Relationships A Guide to MySQL 9  Entity (like a noun): person, place, thing or event  Attribute (like an adjective or adverb): property of an entity  Describes the entity ex. Fiction may be an attribute of Book  Belongs to the entity ex. Address may be associated with a Person  Relationship: association between entities

Entities, Attributes, and Relationships (continued) A Guide to MySQL 10  Cardinality: numeric relationships between occurrences of the entities on either end of a relationship line  One-to-one  One-to-many One rep is related to many customers; but customers have a single rep Implement by having a common column in two or more tables  Many-to-many

Entities, Attributes, and Relationships (continued) A Guide to MySQL 11  Repeating groups: multiple entries in an individual location (multiple entries in the same column of a single row)  Repeating groups merely take up space and resources and  Repeating groups add no additional information

A Guide to MySQL 12

A Guide to MySQL 13

Entities, Attributes, and Relationships (continued) A Guide to MySQL 14  A relation is a two-dimensional table:  Entries in the table are single-valued  Each column has a distinct name  All values in a column are values of the same attribute  The order of the columns is immaterial  Each row is distinct  The order of the rows is immaterial

Entities, Attributes, and Relationships (continued) A Guide to MySQL 15  Use shorthand representation to show tables and columns REP (REP_NUM, LAST_NAME, FIRST_NAME, STREET, CITY, STATE, ZIP, COMMISSION, RATE) CUSTOMER (CUSTOMER_NUM, CUSTOMER_NAME, STREET, CITY, STATE, ZIP, BALANCE, CREDIT_LIMIT, REP_NUM) ORDERS (ORDER_NUM, ORDER_DATE, CUSTOMER_NUM) ORDER_LINE (ORDER_NUM, PART_NUM, NUM_ORDERED, QUOTED_PRICE) PART (PART_NUM, DESCRIPTION, ON_HAND, CLASS, WAREHOUSE, PRICE)

Entities, Attributes, and Relationships (continued) A Guide to MySQL 16  Qualify a name: refers to the process of qualifying a name by concatenating the name of the table with the name of the attribute  It is always acceptable to qualify column names (attributes), even if there is no potential for confusion.  Example: a museum has a database with tables: customer, friends, and employees. How can confusion arise if attributes are not qualified in a discussion of this database?

Functional Dependence A Guide to MySQL 17  An attribute, B, is functionally dependent on another attribute (or collection), A, if a value for A determines a single value for B at any one time  Functional dependencies cannot determine from sample data; must know the users’ policies  Example: Compare a retail salesperson’s relationship to a customer with a drug representative visiting a doctor. In either case, explain how the relationship can be one-to-many or many-to-many.  Why are the business rules needed to answer this question?

A Guide to MySQL 18 Functional Dependence

Primary Keys A Guide to MySQL 19  Unique identifier for a table  Column (attribute) A (or a collection of columns) is the for a table (relation) R if:  Property 1: all columns in R are functionally dependent on A  Property 2: no subcollection of the columns in A (assuming that A is a collection of columns and not just a single column) also has Property 1

Database Design A Guide to MySQL 20  Design a database given a set of requirements that database must support  Requirements gathered through a process known as systems analysis  In many cases problems are not obvious at the early design steps  Have someone play devil’s advocate  Try to mentally “run” the data

Design Method A Guide to MySQL 21 Read requirements, identify entities (objects) involved, and name the entities. Identify unique identifiers for entities identified above Identify the attributes for all entities Identify functional dependencies that exist among attributes Use functional dependencies to identify tables by placing each attribute with attribute or minimum combination of attributes on which it is functionally dependent Identify any relationships between tables

Database Design Requirements A Guide to MySQL 22  For Premiere Products:  Store data about sales reps, customers, parts, orders, and order line items  Must enforce certain constraints; for example: There is only customer per order Quoted price may differ from actual price

Normalization A Guide to MySQL 23  Identify the existence of potential problems  Provides a method for correcting problems  Goal: convert unnormalized relations (tables that contain repeating groups) into various types of normal forms  Is complete normalization necessary in all cases?  Why or why not?  What is the bottom line for design?

Normalization (continued) A Guide to MySQL 24  First normal form (1 NF): better than unnormalized  Second normal form (2 NF): better than 1 NF  Third normal form (3 NF): better than 2 NF

First Normal Form (1NF) A Guide to MySQL 25  A relation is in first normal form (1NF) if it does not contain any repeating groups (multiple entries in a single row)  To convert an unnormalized relation to 1NF: expand PK to include PK of repeating group (effectively eliminating the repeating group from the relation)  Does first normal form indicate anything about cardinality? (Look at the next two slides and come back to this question)

A Guide to MySQL 26

A Guide to MySQL 27

Second Normal Form A Guide to MySQL 28  Redundancy causes problems  Example a part with multiple descriptions pg. 46/7  Update anomalies  Update - If one description is changed; it doesn’t change the other description.  Inconsistent data - Part descriptions now disagree.  Additions – What description will be applied to a new part?  Deletions – instantiation vs. storage

Second Normal Form (continued) A Guide to MySQL 29  A relation is in second normal form (2NF) if it is in 1NF and no nonkey attribute is dependent on only a portion of the primary key  Or: all nonkey attributes are functionally dependent on entire primary key  If the primary key is a single column of a table in 1NF, then the table is automatically in 2NF.

A Guide to MySQL 30

Third Normal Form A Guide to MySQL 31  Update anomalies still possible  Determinant: an attribute (or collection) that functionally determines another attribute  A relation is in third normal form (3NF) if it is in 2NF and the only determinants it contains are candidate keys  Boyce-Codd normal form (BCNF) is the true name for this version of 3NF

A Guide to MySQL 32

Diagrams for Database Design A Guide to MySQL 33  Graphical illustration  Entity-relationship (E-R) diagram:  Rectangles represent entities  Arrows represent relationships

A Guide to MySQL 34 Diagrams for Database Design (continued)

A Guide to MySQL 35 Diagrams for Database Design (continued)

A Guide to MySQL 36 Diagrams for Database Design (continued)