How to design a database

Similar documents
SQL Workshop. Database Design. Doug Shook

Database Foundations. 3-9 Validating Data Using Normalization. Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 6 Normalization of Database Tables

From Murach Chap. 9, second half. Schema Refinement and Normal Forms

Learning outcomes. On successful completion of this unit you will: 1. Understand data models and database technologies.

A Guide to SQL, Ninth Edition. Chapter Two Database Design Fundamentals

Introduction to relational databases and MySQL

Database Application Development Oracle PL/SQL, part 2. CS430/630 Lecture 18b

Lecture 9: Database Design. Wednesday, February 18, 2015

Introduction to Data Modeling with MySQL Workbench

Chapter 1 An introduction to relational databases and SQL

Database Systems. Normalization Lecture# 7

Steps in normalisation. Steps in normalisation 7/15/2014

Normalization Rule. First Normal Form (1NF) Normalization rule are divided into following normal form. 1. First Normal Form. 2. Second Normal Form

8) A top-to-bottom relationship among the items in a database is established by a

Information Systems Development COMM005 (CSM03) Autumn Semester 2009

پوهنتون کابل پوهنحی كمپيوترساینس پوهنیار محمد شعیب "زرین خیل"

Chapter 9: MySQL for Server-Side Data Storage

Chapter 11 How to create databases, tables, and indexes

Systems Analysis & Design

Normalization in DBMS

In This Lecture. Normalisation to BCNF. Lossless decomposition. Normalisation so Far. Relational algebra reminder: product

Test Bank for A Guide to SQL 9th Edition by Pratt

Access Tutorial 2 Building a Database and Defining Table Relationships

Test Bank For A Guide To Mysql 1st Edition By Pratt And Last

Link download full of Solution Manual:

Normalization. VI. Normalization of Database Tables. Need for Normalization. Normalization Process. Review of Functional Dependence Concepts

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 9 Normalizing Database Designs

New Perspectives on Microsoft Access Module 2: Building a Database and Defining Table Relationships

Munis Self Service Vendor Self Service

CMP-3440 Database Systems

NORMAL FORMS. CS121: Relational Databases Fall 2017 Lecture 18

Microsoft Office Access 2007: Intermediate Course 01 Relational Databases

Accounts Receivable Customer

Entity Relationship Diagram (ERD) Dr. Moustafa Elazhary

This is an almost-two week homework; it is almost twice as long as usual. You should complete the first half of it by October 2.

Systems Analysis & Design

Chapter 3. Introduction to relational databases and MySQL. 2010, Mike Murach & Associates, Inc. Murach's PHP and MySQL, C3

Database Management Systems

Relational Databases and Web Integration. Week 7

Genesis Advantage. Version 7

Concepts of Database Management Seventh Edition. Chapter 4 The Relational Model 3: Advanced Topics

1. The process of determining the particular tables and columns that will comprise a database is known as database design.

Database Normalization. (Olav Dæhli 2018)

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

CSE 562 Database Systems

ch02 True/False Indicate whether the statement is true or false.

7) To be considered a composite key, a key must contain at least two attributes. Answer: TRUE

Chapter 3 Introduction to relational databases and MySQL

CSE 308. Database Issues. Goals. Separate the application code from the database

Sage 300. Sage CRM 7.3 Integration Upgrade Guide

Vendor Payment Remittance Portal User Guide

Database Tables and Normalization

Chapter 11: Data Management Layer Design

Institute of Southern Punjab, Multan

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization

Introduction to Databases

Data and Knowledge Management Dr. Rick Jerz

Normal Forms. Winter Lecture 19

Applied Databases. Sebastian Maneth. Lecture 5 ER Model, Normal Forms. University of Edinburgh - January 30 th, 2017

MIS2502: Data Analytics Relational Data Modeling. Jing Gong

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization

Database Management System Prof. Partha Pratim Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Supplier Enablement Quick Reference Guide (QRG) October 2017

Oracle SQL. murach s. and PL/SQL TRAINING & REFERENCE. (Chapter 2)

Exam I Computer Science 420 Dr. St. John Lehman College City University of New York 12 March 2002

IS 263 Database Concepts

Applied Databases. Sebastian Maneth. Lecture 5 ER Model, normal forms. University of Edinburgh - January 25 th, 2016

Lecture 3: Continuing SQL. Monday, February 2, 2015

Relational Design: Characteristics of Well-designed DB

Data and Knowledge Management. Goals. Big Data. Dr. Rick Jerz

New Features in Sage BusinessVision 2019 ( )

Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 10-2

Chapter 10. Chapter Outline. Chapter Outline. Functional Dependencies and Normalization for Relational Databases

Normalization. Normal Forms. Normal Forms

Introduction to Databases

RELATIONAL DATABASE DESIGN. Basic Concepts

Sage ERP Accpac Online 5.5

Unit 3 : Relational Database Design

Chapter 8: Relational Database Design

Welcome. CE Tips, Tricks and Shortcuts

DBMS Chapter Three IS304. Database Normalization-Comp.

CSCI 403: Databases 13 - Functional Dependencies and Normalization

SQL Interview Questions

Animation: Enter Vouchers by Item or Amount?

Normalization. Anomalies Functional Dependencies Closures Key Computation Projecting Relations BCNF Reconstructing Information Other Normal Forms

Chapter 4 How to retrieve data from two tables

Relational Database Design (II)

Geodatabase Database Design. Tomislav Sapic GIS Technologist Faculty of Natural Resources Management Lakehead University

Chapter 3B Objectives. Relational Set Operators. Relational Set Operators. Relational Algebra Operations

Accounting Information Systems, 2e (Kay/Ovlia) Chapter 2 Accounting Databases. Objective 1

The Relational Model and Normalization

Relational Model. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan

33:010:458 Accounting Information Systems

Conceptual Design. The Entity-Relationship (ER) Model

Accounts Payable Vendor Portal Vendor Functions.

Normalization. Un Normalized Form (UNF) Share. Download the pdf version of these notes.

Homework Assignment 3. November 9th, 2017 Due on November 23th, 11:59pm (midnight) CS425 - Database Organization Results

Inside Relational Databases with Examples in Access

Data Modeling, Normalization and Denormalization

Transcription:

Chapter 16 How to design a database A database system is modeled after a real-word system 2017, Mike Murach & Associates, Inc. C 16, Slide 1 2017, Mike Murach & Associates, Inc. C 16, Slide 4 Objectives Applied 1. Given the specifications for a database modeled on a real-world system, design the database. That is, identify the tables, columns, keys, relationships, and indexes for the new database. 2. Given a diagram for an unnormalized database, normalize the structure to the third normal form. 3. Use MySQL Workbench to create database diagrams. The six basic steps for designing a data structure Step 1: Identify the data elements Step 2: Subdivide each element into its smallest useful components Step 3: Identify the tables and assign columns Step 4: Identify the primary and foreign keys Step 5: Review whether the data structure is normalized Step 6: Identify the indexes 2017, Mike Murach & Associates, Inc. C 16, Slide 2 2017, Mike Murach & Associates, Inc. C 16, Slide 5 Objectives (continued) Knowledge 1. Describe the process of designing a database in terms of tables, columns, keys, and relationships. 2. Describe referential integrity, and explain how enforcing it assures that the database isn t corrupted when rows are inserted, updated, or deleted. 3. Explain how normalizing a database to the third normal form improves database performance. 4. In general terms, describe the criteria for indexing a column. An invoice that can be used to identify data elements 2017, Mike Murach & Associates, Inc. C 16, Slide 3 2017, Mike Murach & Associates, Inc. C 16, Slide 6 1

The data elements identified on the invoice Vendor name Invoice date Item extension Vendor address Invoice terms Vendor contact name Vendor phone number Item part number Vendor contact ext. Vendor fax number Item quantity Vendor AR contact name Vendor web address Item description Vendor AR contact ext. Invoice number Item unit price Invoice total Possible tables and columns for an A/P system Vendors table Vendor name Vendor address Vendor city Vendor state Vendor zip code Vendor phone number Vendor fax number Vendor web address Vendor contact first name Vendor contact last name Vendor contact phone Vendor AR first name Vendor AR last name Vendor AR phone Terms* Data elements that were added *Data element related to two or more entities 2017, Mike Murach & Associates, Inc. C 16, Slide 7 2017, Mike Murach & Associates, Inc. C 16, Slide 10 A name that s divided into first and last names Possible tables and columns for an A/P system (continued) Invoices table Invoice number* Invoice date Terms* Invoice total Payment date Payment total Invoice due date Credit total Invoice line items table Invoice number* Item part number Item quantity Item description Item unit price Item extension Sequence number 2017, Mike Murach & Associates, Inc. C 16, Slide 8 2017, Mike Murach & Associates, Inc. C 16, Slide 11 An address that s divided into street address, city, state, and zip code The relationships between the tables in the accounts payable system 2017, Mike Murach & Associates, Inc. C 16, Slide 9 2017, Mike Murach & Associates, Inc. C 16, Slide 12 2

Two tables with a many-to-many relationship The accounts payable system in third normal form Two tables with a one-to-one relationship 2017, Mike Murach & Associates, Inc. C 16, Slide 13 2017, Mike Murach & Associates, Inc. C 16, Slide 16 Operations that can violate referential integrity This operation Violates referential integrity if Delete a row from the primary key table The foreign key table contains one or more rows related to the deleted row Insert a row in the foreign key table The foreign key value doesn t have a matching primary key value in the related table Update the value of a foreign key The new foreign key value doesn t have a matching primary key value in the related table Update the value of a primary key The foreign key table contains one or more rows related to the row that s changed About indexes An index provides a way for a database management system to locate information more quickly. MySQL automatically creates an index for a primary key. You can create composite indexes of two or more columns. Because indexes must be updated each time you add, update, or delete a row, don t create more indexes than you need. When to create an index When the column is a foreign key When the column is used frequently in search conditions or joins When the column contains a large number of distinct values When the column is updated infrequently 2017, Mike Murach & Associates, Inc. C 16, Slide 14 2017, Mike Murach & Associates, Inc. C 16, Slide 17 A table that contains repeating columns A table that contains redundant data The seven normal forms First (1NF) Second (2NF) Third (3NF) Boyce-Codd (BCNF) Fourth (4NF) Fifth (5NF) Domain-key (DKNF) or Sixth (6NF) 2017, Mike Murach & Associates, Inc. C 16, Slide 15 2017, Mike Murach & Associates, Inc. C 16, Slide 18 3

The benefits of normalization Since a normalized database has more tables than an unnormalized database, and since each table has an index on its primary key, the database has more indexes. That makes data retrieval more efficient. Since each table contains information about a single entity, each index has fewer columns (usually one) and fewer rows. That makes data retrieval and insert, update, and delete operations more efficient. Each table has fewer indexes, which makes insert, update, and delete operations more efficient. Data redundancy is minimized, which simplifies maintenance and reduces storage. The invoice data in first normal form with keys added 2017, Mike Murach & Associates, Inc. C 16, Slide 19 2017, Mike Murach & Associates, Inc. C 16, Slide 22 The invoice data with a column that contains repeating values The invoice data in second normal form The invoice data with repeating columns 2017, Mike Murach & Associates, Inc. C 16, Slide 20 2017, Mike Murach & Associates, Inc. C 16, Slide 23 The invoice data in first normal form The A/P system in second normal form Questions about the structure 1. Does the vendor information depend only on the invoiceid column? 2. Does the terms column depend only on the invoiceid column? 3. Does the accountno column depend only on the invoiceid column? 4. Can the invoiceduedate and lineitemamount columns be derived from other data? 2017, Mike Murach & Associates, Inc. C 16, Slide 21 2017, Mike Murach & Associates, Inc. C 16, Slide 24 4

The A/P system in third normal form MySQL Workbench Lets you create and edit diagrams. Lets you define the tables, columns, and indexes for a database. Lets you define the relationships between the tables in a database. Lets you generate a diagram from a SQL creation script. Lets you generate a SQL creation script from a diagram. How to install MySQL Workbench 1. Go to the MySQL Workbench web site at: http://www.mysql.com/products/workbench 2. Download the version for your system. 3. Run the installer or setup file and respond to the prompts. 2017, Mike Murach & Associates, Inc. C 16, Slide 25 2017, Mike Murach & Associates, Inc. C 16, Slide 28 The accounts payable system in fifth normal form The Welcome tab of the Home page 2017, Mike Murach & Associates, Inc. C 16, Slide 26 2017, Mike Murach & Associates, Inc. C 16, Slide 29 When to denormalize When a column from a joined table is used repeatedly in search criteria, you should consider moving that column to the primary key table if it will eliminate the need for a join. If a table is updated infrequently, you should consider denormalizing it to improve efficiency. Because the data remains relatively constant, you don t have to worry about data redundancy errors once the initial data is entered and verified. Include columns with derived values when those values are used frequently in search conditions. If you do that, you need to be sure that the column value is always synchronized with the value of the columns it s derived from. MySQL Workbench 2017, Mike Murach & Associates, Inc. C 16, Slide 27 2017, Mike Murach & Associates, Inc. C 16, Slide 30 5