Order Entry System Please use speaker notes for additional information!

Slides:



Advertisements
Similar presentations
Relational Database Example in Access - Order System Please use speaker notes for additional information!
Advertisements

Reports Using SQL Script Please check speaker notes for additional information!
Group functions using SQL Additional information in speaker notes!
Relational example using donor, donation and drive tables For additional information see the speaker notes!
Athabasca University Under Development for COMP 200 Gary Novokowsky
Accounting 6500 Relational Databases: Accounting Applications Introduction to Normalization.
Information Resources Management March 13, Agenda n Administrivia n Normalization n Homework #7 n Mid-Term #2.
The Relational Database Model:
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 David M. Kroenke Database Processing Chapter 3 Normalization.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Database Normalization CP3410 Daryle Niedermayer, I.S.P., PMP.
Table maintenance revisited (again) Please use speaker notes for additional information!
SQL Use of Functions Character functions Please use speaker notes for additional information!
CS370 Spring 2007 CS 370 Database Systems Lecture 7 The Relational model.
Week 6 Lecture Normalization
A Guide to SQL, Eighth Edition Chapter Two Database Design Fundamentals.
SQL – Part II Yong Choi School of Business CSU, Bakersfield.
Relational databases and third normal form As always click on speaker notes under view when executing to get more information!
More on variables with Oracle’s SQL*Plus As always, speaker notes will contain additional information!
More on relational databases, including 1 to 1, 1 to many and many to many relationships Please use speaker notes for additional information!
Normalization A technique that organizes data attributes (or fields) such that they are grouped to form stable, flexible and adaptive entities.
1 A Guide to MySQL 2 Database Design Fundamentals.
Module III: The Normal Forms. Edgar F. Codd first proposed the process of normalization and what came to be known as the 1st normal form. The database.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Concepts of Relational Databases. Fundamental Concepts Relational data model – A data model representing data in the form of tables Relations – A 2-dimensional.
資料庫正規化 Database Normalization 取材自 AIS, 6 th edition By Gelinas et al.
Database Normalization Lynne Weldon July 17, 2000.
In this chapter, you learn about the following: ❑ Anomalies ❑ Dependency and determinants ❑ Normalization ❑ A layman’s method of understanding normalization.
Chapter 7 1 Database Principles Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that.
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Applicants Please use speaker notes for additional information!
Relationships and Advanced Query Concepts Using Multiple Tables Please use speaker notes for additional information!
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
Microsoft Access Big City Store Sales Database CUSTOMERS First Last Address City State Zip PRODUCTS Product Supplier Description Units Cost Price SALES.
XML and DTD Please you speaker notes for additional information!
1 A Guide to MySQL 2 Database Design Fundamentals.
SQL- DQL (Oracle Version). 2 SELECT Statement Syntax SELECT [DISTINCT] column_list FROM table_list [WHERE conditional expression] [GROUP BY column_list]
More on views Please refer to speaker notes for additional information!
SQL and Conditions Speaker notes will provide additional information!
ITN Table Normalization1 ITN 170 MySQL Database Programming Lecture 3 :Database Analysis and Design (III) Normalization.
Order Entry Program Please see speaker notes for additional information!
Exceptions in PL/SQL Please use speaker notes for additional information!
Indexes in Oracle An Introduction Please check speaker notes for additional information!
Introduction to Oracle - SQL Additional information is available in speaker notes!
A337 - Reed Smith1 Structure What is a database? –Table of information Rows are referred to as records Columns are referred to as fields Record identifier.
Competitive (Business) Intelligence Systems The Road to Denormalization (starring Charlie Sheen & other Random Celebrities)
An Introduction To SQL Part 2 (Special thanks to Geoff Leese)
1 Information Retrieval and Use (IRU) An Introduction To SQL Part 2.
More on Primary and Foreign Keys Please see speaker notes for additional information!
Understand Primary, Foreign, and Composite Keys Database Administration Fundamentals LESSON 4.2.
Relational Database in Access Student System As always please use speaker notes!
Logical Database Design and the Relational Model.
DO NOT COPY --CONFIDENTIAL Homework 5 Partial Key Star Diagrams & Data Warehouse Design BCIS 4660 Dr. Nick Evangelopoulos Spring 2012.
PHP with MYSQL Please use speaker notes for additional information!
Lecture 4: Logical Database Design and the Relational Model 1.
INFS 6220 Systems Analysis & Design Transactional DBs vs. Data Warehouses.
What Is Normalization  In relational database design, the process of organizing data to minimize redundancy  Usually involves dividing a database into.
More SQL functions As usual,there is additional information in the speaker notes!
Normalisation Worked example for an Order Remember : The data should depend upon the key, the whole key and nothing but the key.
NORMALISATION OF DATABASES. WHAT IS NORMALISATION? Normalisation is used because Databases need to avoid have redundant data, which makes it inefficient.
A Guide to SQL, Eighth Edition
Database, tables and normal forms
Database Normalization
MySQL - Creating donorof database offline
Normalization Referential Integrity
Database Normalization
Enterprise Conceptual Relational
Creating Tables & Inserting Values Using SQL
Looking at using multiple tables
This shows the tables that I made for the order system.
Presentation transcript:

Order Entry System Please use speaker notes for additional information!

Product Data: Item Number Item Name On Hand On Order Reorder Point Cost Price Department Number Department Name Department Manager Item Class Warehouse Location Customer Data: Customer Number Customer Name Street Address City State Zip Past Due Current Due Credit Limit Date First Bought Sales Representative Number Sales Representative Name Commission Rate Order Data: Customer Placing Order Order Date Item Number Ordered (allow multiple) Number Ordered of Item

Product Data: Item Number Item Name On Hand On Order Reorder Point Cost Price Department Number Department Name Department Manager Item Class Warehouse Location I will use the product data to create a product or inventory table. This will contain all of the information about the products carried in the inventory. Each product will be assigned a unique identification number (Item Number) which I can use as the primary key. The only problem that I see relates to Department. Department Name and Department Manager relate directly to the Department Number. Department Number is therefore the determinant. I cannot carry Department Name and Department Manager in the table or I will break the rules of normalization. Therefore I will create a separate Department Table that will be linked to the Inventory Table by Department Number. The rest of the data shown under Product Data directly relates to the Item and the Item Number which I have designated as the primary key.

Product Data: Item Number Item Name On Hand On Order Reorder Point Cost Price Department Number Department Name Department Manager Item Class Warehouse Location Item Item On On Reorder Cost Price Department Department Department Item Warehouse Number Name Hand Order Point Number Name Manager Class Location Dependency Chart

Product Data: Item Number Item Name On Hand On Order Reorder Point Cost Price Department Number Department Name Department Manager Item Class Warehouse Location Inventory Table Itemno primary key ItemName OnHand OnOrder ReOrdPt Cost Price Dept foreign key ItemClass Location Department Table Dept primary key DeptName Manager

Customer Data: Customer Number Customer Name Street Address City State Zip Past Due Current Due Credit Limit Date First Bought Sales Representative Number Sales Representative Name Commission Rate The data about the customer will go onto a Customer Table with the Customer Number as the primary key. There are no other candidate keys. Customer Name has the possibility of being duplicated so it is not a valid candidate key. All of the data listed here directly relates to the Customer Number except the Sales Representative Name and the Commission Rate. These relate to the Sales Representative Number which is therefore the determinant. I need to pull the information about the Sales Representative out and put it in a separate table or I will break the rules of 3NF.

Customer Data: Customer Number Customer Name Street Address City State Zip Past Due Current Due Credit Limit Date First Bought Sales Representative Number Sales Representative Name Commission Rate Cust Cust Street City State Cost Zip Past Current Date SalesRep SalesRep Commission Number Name Adr Due Due First Number Name Dependency Chart

Customer Data: Customer Number Customer Name Street Address City State Zip Past Due Current Due Credit Limit Date First Bought Sales Representative Number Sales Representative Name Commission Rate Customer Table Custid primary key CustName StAdr City State Zip PastDue CurrDue CrLimit DateFst SlsRep foreign key SalesRep Table SlsRep primary key SalesName CommRate

Order Data: Customer Placing Order Order Date Item Number Ordered (allow multiple) Number Ordered of Item I have several problems with the Order Data. First, there is no field that can serve as the identification number. In this situation it is a good idea to make my own candidate key which I will use as the primary key. I have decided to assign an Order Number which would be assigned by the system when the order is placed. I will set it up so the system will keep track of the order number and assign the next available order number to a new order. Second, Item Number Ordered allows for multiple. This means I would break the rules of 1NF and have repeating groups. I have also noticed that the Number Ordered of Item must be multiple as well to allow the customer to order a different number for ech item being ordered. Order Data: Order Number Customer Placing Order Order Date Item Number Ordered (allow multiple) Number Ordered of Item

Order Data: Order Number Customer Placing Order Order Date Item Number Ordered (allow multiple) Number Ordered of Item OrderHeader Table OrdNo primary key CustId foreign key OrdDate OrderLine Table OrdNo foreign key primary ItemNo foreign key key NumOrd In the OrderLine Table, I have established that the primary key is made up of two fields: the OrdNo and the ItemNo. If OrdNo alone was sufficient for the key, I would not have had to make the OrderLine Table, I could have simply carried the one item on the OrderHeader Table. Combining OrdNo with ItemNo gives a unique key assuming that a customer only orders an item once during an order. OrdNo is not only part of the primary key, it is also a foreign key linking back to the OrderHeader Table. It should also be noted that I have met the requirements of 2NF because all of the data in the OrderLine Table relates to the entire key. I do not have any non-key attributes that are dependent on only a part of the primary key.

Order Data: Order Number Customer Placing Order Order Date Item Number Ordered (allow multiple) Number Ordered of Item OrderHeader Table OrdNo primary key CustId foreign key OrdDate OrderLine Table OrdNo foreign key primary ItemNo foreign key key LineNo NumOrd Adding the LineNo column allows the customer to order an ItemNo twice in the order.

Order Data: Order Number Customer Placing Order Order Date Item Number Ordered (allow multiple) Number Ordered of Item OrderHeader Table OrdNo primary key CustId foreign key OrdDate OrderLine Table OrdNo foreign key primary ItemNo foreign key key NumOrd QuotedPrice Now I am adding QuotedPrice to the OrderLine Table. On first look, it might appear that QuotePrice only applies to ItemNo and therefore breaks the 2NF rule which says that every column must be dependent on the whole primary key. However, the QuotedPrice is the specific price quoted for this specific order so it applies to the whole primary key and the table remains normalized.

SQL> DESC inven; Name Null? Type ITEMNO NOT NULL VARCHAR2(4) ITEMNAME VARCHAR2(15) ONHAND NUMBER(5) ONORDER NUMBER(5) REORDPT NUMBER(5) COST NUMBER(6,2) PRICE NUMBER(6,2) DEPT CHAR(2) ITEMCLASS CHAR(2) LOCATION VARCHAR2(4) SQL> SELECT * FROM inven; ITEM ITEMNAME ONHAND ONORDER REORDPT COST PRICE DE IT LOCA Good Night Moon BK BY X Heidi BK CH X Adven Reddy Fox BK CH X Teddy Bear TY CH X Building Blocks TY CH Z Doll House TY CH Z Basketball SP BK Y Net/Hoop SP BK Y200 8 rows selected. Itemno primary key ItemName OnHand OnOrder ReOrdPt Cost Price Dept foreign key ItemClass Location Inventory Table

SQL> DESC dept; Name Null? Type DEPTNO NOT NULL NUMBER(2) DNAME VARCHAR2(14) LOC VARCHAR2(13) SQL> SELECT * FROM dept; DEPTNO DNAME LOC ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON Department Table Dept primary key DeptName Manager

Customer Table Custid primary key CustName StAdr City State Zip PastDue CurrDue CrLimit DateFst SlsRep foreign key SQL> DESC invcust; Name Null? Type CUSTID NOT NULL VARCHAR2(5) CUSTNAME VARCHAR2(20) STADR VARCHAR2(15) APT VARCHAR2(5) CITY VARCHAR2(15) STATE CHAR(2) ZIP VARCHAR2(5) PASTDUE NUMBER(6,2) CURRDUE NUMBER(6,2) CRLIMIT NUMBER(6,2) DATEFST DATE SLSREP VARCHAR2(4) SQL> SELECT * FROM invcust; CUSTI CUSTNAME STADR APT CITY ST ZIP PASTDUE CURRDUE CRLIMIT DATEFST SLSR Susan Ash 123 Elm St Fall River MA NOV Richard Davis 24 West St Fall River MA DEC Linda Anderson 45 Main St A#3 Seekonk MA OCT

SalesRep Table SlsRep primary key SalesName CommRate SQL> DESC salsrep; Name Null? Type SALSREP NOT NULL VARCHAR2(4) SALSNAME VARCHAR2(20) COMMRATE NUMBER(3,2) SQL> SELECT * FROM salsrep; SALS SALSNAME COMMRATE John Smith Joanne London.09

SQL> DESC orderz; Name Null? Type ORDNO NOT NULL VARCHAR2(6) CUSTID VARCHAR2(5) ORDATE DATE SQL> SELECT * FROM orderz; ORDNO CUSTI ORDATE JUN JUN JUN JUL-99 OrderHeader Table OrdNo primary key CustId foreign key OrdDate

OrderLine Table OrdNo foreign key primary ItemNo foreign key key NumOrd QuotedPrice SQL> DESC ordline; Name Null? Type ORDNO NOT NULL VARCHAR2(6) ITEMNO NOT NULL VARCHAR2(4) NUMORD NUMBER(3) SQL> SELECT * FROM ordline; ORDNO ITEM NUMORD rows selected.