CS251: Fundamentals of Database Systems 1 CS251: Fundamentals of Database Systems Database Design Project Trina VanderLouw Professor Stephanie Fisher Colorado Technical University Online March 14, 2011 Highlights: File-based and Server-based Databases, Normalization and Redundancy, Relational Models and Entity Relationship Diagrams (ERD), Database Design, SQL Statements, Reports and Menus (UI) Programs Used: Microsoft Word, Microsoft Access, Microsoft PowerPoint, CTU Virtual Campus, Adobe Connect Instructor Feedback: Trina, Great work overall on this class. You did well with your template. You really went above and beyond including all of the forms, menus and reports you created. You covered all of the expectations for this assignment. Good luck in the future. It was a pleasure to have you in class. Final Grade: A
CS251: Fundamentals of Database Systems 2 Table of Contents Project Outline... 3 Description of the database design life cycle (Week 1 IP)... 3 A description of the DBDSL... 3 A discussion about the three steps in database design... 6 The entity relationship diagram (Week 2 IP)... 7 An entity relationship diagram... 7 The logical model and normalization (Week 3 IP)... 9 Logical data model... 9 Second Normal Form:... 12 Normalized to 3NF... 12 The Microsoft Access database (Week 4 IP)... 16 Database created in Microsoft Access... 16 SQL SELECT statements... 17 The Microsoft Access database application (Week 5 IP)... 20 Forms... 20 Reports... 21 VIP Business Members Report... 21 References... 23
CS251: Fundamentals of Database Systems 3 Project Outline Description of the database design life cycle (Week 1 IP) A description of the DBDSL There are seven steps in the design process: 1. Defining a mission statement and mission objectives 2. Analyzing the current database 3. Creating the data structures 4. Determining and establishing table relationships 5. Determining and defining business rules 6. Determining and defining views 7. Reviewing data integrity The first is defining a mission statement and objectives. The statement is what will give purpose and focus for your database (Hernandez, 2003, p 79). The statement is necessary because it will define what needs to be accomplished and gives direction in the design process. It is a critical assessment of what information or data will be needed to accomplish the task at hand. The mission objectives are statements that represent the general tasks your users can perform against the data in the database (Hernandez, 2003, p 80). During this phase of the design process you will be working with owners, managers, developers, and end users. Each of these people will give insight and definition to the objectives of the project.
CS251: Fundamentals of Database Systems 4 The second phase is analyzing the current database. This step may be optional if there is no previous or current database. Many of the current databases will be a legacy database or a paper-based database. A legacy database is an inherited database. The paper based system consists of forms, index cards, folders, etc. Analyzing the current database will give valuable insight on the use of information and data by an organization. (Hernandez, 2003, p 80) Part of phase two will include interviews with the management. This will help the developer know what the needs are of the organization. The developer can ask questions about how it is used, what they like about the current system, and what they would like to change or see implemented. From these interviews and analysis the developer can then define the fields. The calculation fields will be placed in a separate list. Then the fields are reviewed by the management for further refinement. The third phase is creating the data structures. This part of the design process is where tables and fields will be defined. Keys will be set and the field specifications defined. Tables will be defined first with fields being added next. It is important to review the tables for possible duplication of data fields. Once that is completed and refined the primary keys will be defined and is set to uniquely identify each record. The last part of phase three is to establish field specifications for each field. You accomplish this by conducting interviews with users and management. After the review with users and management and the refining is complete the structure is ready for phase four. (Hernandez, 2003, p 82) Phase four includes a database-design process. This phase also requires interviews to identify proper relationships with the data. It is important to complete this step to ensure relationship integrity. The next step is to establish the connections using primary keys or linking
CS251: Fundamentals of Database Systems 5 tables (Hernandez, 2003, p 84). The relationships can be defined as one-to-one, one-to-many or many-to-many (Fisher, 2011, Live Chat 2). In phase five of the design process business rules will be determined and defined. Again interviews will be held to help identify limitations and establish business rules. During this phase you will also define and implement validation tables. Once the constraints are identified they become business rules. An example of a specific business rule is setting the limitation that an order date must precede the shipping date. A general rule would be limitations on the amount of entertainers that an agency can represent. The business rules will change as time goes on but it is important to have these limitations in place to help with data integrity (Hernandez, 2003, pp 84-85). The sixth phase of the process is where views will be determined and defined. This phase will use interviews as well with users and management to understand their needs for accessing and viewing the data and information. Each group of users will use the information differently so setting and creating unique views will be helpful in productivity of each of those control groups. After the interviews are completed the views will be put in place and you are ready for that last phase of the design process (Hernandez, 2003, p 85). The last phase, seventh of the design process, is to review the integrity of data. The steps are to review each table for proper design and structure, resolve inconsistencies and review again, then to review and check each of the field specifications, make refinements and review, then review validity of relationships and confirm the type of relationship specified, and review all of the business rules that were identified and confirm the limitations (Hernandez, 2003, p 86).
CS251: Fundamentals of Database Systems 6 Once all seven phases are completed the initial design process is complete. The database will be refined and reviewed over time as the organization changes and evolves. There will be on-going needs to make adjustments to the original design process. A discussion about the three steps in database design There are three steps in the database creation including conceptual, logical and physical data modeling. Each of these steps is important to consider in creating a functional database. The complexity of these types of models will increase from conceptual design, to logical design, and finally to physical design. It is important to start with the conceptual to understand the different entities in the data. Once that is complete then you can move on to the logical where you will insert details of the data without actually implementing them, and finally move to the physical data where it will be determined exactly how the data model will interact with the database (Conceptual, 2011). The conceptual model includes entity names and relationships. The logical will also include the entity names and relationships, but will also include attributes, primary keys, and foreign keys. The last model is the physical model which includes primary and foreign keys, table names, column names, and column data types (Conceptual, 2011).
CS251: Fundamentals of Database Systems 7 The entity relationship diagram (Week 2 IP) An entity relationship diagram
CS251: Fundamentals of Database Systems 8 In the ERD the relationships are one-to-many or one-to-one. The Product-Invoice entity was created to dissolve the many-to-many relationship that existed between the Product entity and the Invoice Entity. The following table shows the relationships. One customer can have many shipping IDs and invoices. One product can be on many invoices. One shipping ID can have many products and one invoice ID. And one invoice can have one customer, many products and one shipping ID. Customers Products Shipping Invoice Product-Invoice Customers 1:M 1:M Products 1:M Shipping 1:M 1:1 Invoice 1:1 1:1 1:M
CS251: Fundamentals of Database Systems 9 The logical model and normalization (Week 3 IP) Logical data model After reviewing the ERD from Phase 2 there are changes to be made in order to make the database normalized. The first step was analyzing the database to make it in the First Normal Form. The changes made for that were to separate the products ordered into one attribute with multiple rows instead of multiple columns for recording products ordered. Another change was to separate the phone numbers into area code and phone number, allowing a search to be made by area code. One more change I made was to separate the dates into month, day and year also allowing for searches to be made by a specific range of dates. Once those changes were complete there were no duplicative columns and separate tables existed with related data. There were tables with primary and foreign keys and no repeating groups. After completing the First Normal Form I moved into the Second Normal Form. In this phase of the normalization process I created more tables. I created an Invoice_Product table as a linking table for the Invoice and Products ordered. This dissolved the many-to-many relationship that existed previously. This changed the Invoice table to the Invoice_ID, Customer_ID, Shipping_ID, Invoice_Product ID, and the separated Invoice Dates that are linked to a lookup table for the month and day. After completing this I realized the need to add in an Employee_ID with a relationship to an Employee table. I also added a Payment Table to track the payment terms and types. Once those changes were complete there were subsets of data that were placed in separate tables and the relationships were created with the use of foreign keys. I also checked for redundant data.
Invoice_ID Customer_ID Shipping_ID Product_ID Invoice_Date Payment_Terms Discount Quantity Tax Shipping Shipping_ID Shipping_Date Ship_Method Tracking_ Number Customer_ID First_Name Last_Name Company_Name Mailing_Street_ Address Mailing_ Address2 Mailing_City Mailing_State Mailing_Zip Shipping_Street _Address Shipping_ Address2 Shipping_City Shipping_State Shipping_Zip Phone1 Phone2 Fax Email CS251: Fundamentals of Database Systems 10 In the last phase of the normalization process, the Third Normal Form, I analyzed my relationships and table data and found that there were columns that were not dependent on the primary key and were thus moved to newly created tables. I added a state table as a lookup resource for tables with address properties, added separate tables for shipping methods and terms, changed the customer table to have subsets of contact information such as mailing address, shipping address and phone numbers. I also created tables for employee hire dates, termination dates and codes. I also added a discount table with membership types and the percentage of discount associated with that level of membership. Original Database Set-up: Customer Table Invoice Table Shipping Table
Product_ID Product_ Description Unit_Price Product_Invoice _ID Invoice_ID Product_ID Invoice_ID Customer_ID Shipping_ID Product_ID Invoice_Month Invoice_Day Invoice_Year Payment_Terms Discount Quantity Tax Shipping Shipping_ID Shipping_Month Shipping_Day Shipping_Year Ship_Method Tracking_ Number Customer_ID First_Name Last_Name Company_Name Mailing_Street_ Address Mailing_ Address2 Mailing_City Mailing_State Mailing_Zip Shipping_Street _Address Shipping_ Address2 Shipping_City Shipping_State Shipping_Zip Area_Code Phone Fax Email Product_ID Product_ Description Unit_Price Product_ Invoice _ID Invoice_ID Product_ID CS251: Fundamentals of Database Systems 11 Product Table Product_Invoice Table First Normal Form: Customer Table Invoice Table Shipping Table Product Table Product_Invoice Table
CS251: Fundamentals of Database Systems 12 Second Normal Form: Same as above with new table created for Invoice_Product. Invoice_Product Table Invoice_Product_ID Invoice_ID Product_ID Quantity Invoice Table Invoice_ID Customer_ID Invoice_Product_ID Shipping_ID Invoice_Month Invoice_Day Invoice_Year Employee_ID Payment_ID Normalized to 3NF
CS251: Fundamentals of Database Systems 13 Normalization Matrix Customer Customer_ID First_Name Last_Name Company_Name Mailing_Address Shipping_Address Phone_Numbers Email Discount_Code Invoice Invoice_ID Invoice_Product_ID Customer_ID Shipping_ID Invoice_Date_Month Invoice_Date_Day Invoice_Date_Year Employee_ID Payment_ID Product Product_ID Product_Description Unit_Price Shipping Shipping_ID Ship_Date_Month Ship_Date_Day Ship_Date_Year Ship_Method Ship_Terms Tracking_Number Invoice_Product Invoice_Product_ID Product_ID Quantity Mailing_Address Mailing_Address_ID Street_Address Address_2 City State Zip 1NF 2NF 3NF There are no repeating groups There is no redundant data Separated area code from phone number Separated first and last name of customer There are repeating groups Created an invoice_product table There is no redundant data There are columns not dependent on primary key Created mailing address table, shipping address table, phone numbers table, and discount table Added invoice dates, employee and payment data. New data was not dependent on primary key. Added a lookup table for the month and day. Added an employee table and payment table There are no repeating groups There is no redundant data Added data for shipping carrier and terms. New data was not dependent on primary key Created a ship method and ship terms table Created lookup table for state
CS251: Fundamentals of Database Systems 14 Shipping_Address Shipping_Address_ID Street_Address Address_2 City State Zip Phone_Numbers Phone_Number_ID Home_Area_Code Home_Phone Office_Area_Code Office_Phone Mobile_Area_Code Mobile_Phone Fax Discount_Code Discount_Code_ID Discount_Code Discount_Amount Date_Month Date_Month_ID Date_Month Date_Day Date_Day_ID Date_Day Employee Employee_ID First_Name Last_Name Street_Address Address_2 City State Zip Employee_Hire Employee_Terminate Payment Payment_ID Payment_Type Payment_Terms Ship_Method Ship_Method_ID Carrier Ship_Terms Ship_Terms_ID Ship_Time States State_ID State_Name State_Abbreviation There are no repeating groups Added home, office and mobile phone numbers with separate area codes There is no redundant data Created relationship to States table All data is dependent There are no repeating groups There is no redundant data There is data not dependent on primary key Created an employee hire table and an employee terminate table There are no repeating groups There is no redundant data There is data not dependent on primary key Created a payment type table and a payment terms table
CS251: Fundamentals of Database Systems 15 Employee_Hire Employee_Hire_ID Hire_Date_Month Hire_Date_Day Hire_Date_Year Employee_ Terminate Employee_ Terminate_ID Termination_Date _Month Termination_Date _Day Termination_Date _Year Termination_Type Termination_ Memo Payment_Type Payment_Type_ID Payment_Type Payment_Terms Payment_Terms_ID Payment_Terms Termination_Type Termination_Type_ID Termination_Type Created relationship to lookup tables for Date_Month and Date_Day Created relationship to lookup tables for Date_Month and Date_Day Created table for termination type
CS251: Fundamentals of Database Systems 16 The Microsoft Access database (Week 4 IP) Database created in Microsoft Access
CS251: Fundamentals of Database Systems 17 SQL SELECT statements 1. There has been a recall on all of our HP Laser Toners that were sold this month. We need to call any customers who have purchased them to arrange a product exchange. The query will use the customer table, phone number table, invoice table, product table, and invoice_product table. The results will show the customer s first and last name, home and office phone numbers, description of the product and quantity ordered. The results will hide the invoice information and product ID number. SQL Statement SELECT tbl_customer.first_name, tbl_customer.last_name, tbl_invoice_product.quantity, tbl_product.product_description, tbl_phone_numbers.home_area_code, tbl_phone_numbers.home_phone, tbl_phone_numbers.office_area_code, tbl_phone_numbers.office_phone FROM tbl_phone_numbers INNER JOIN (tbl_customer INNER JOIN (tbl_product INNER JOIN (tbl_invoice_product INNER JOIN tbl_invoice ON tbl_invoice_product.invoice_product_id = tbl_invoice.invoice_product_id) ON tbl_product.product_id = tbl_invoice_product.product_id) ON tbl_customer.customer_id = tbl_invoice.customer_id) ON tbl_phone_numbers.phone_number_id = tbl_customer.phone_numbers WHERE (((tbl_invoice_product.product_id)=1)); qry_recallhpmarch2011 First_Name Last_Name Quantity Product_Description Home_Area_Code Home_Phone Office_Area_Code Office_Phone John Elliot 5 HP Laser Toner 602 275-7520 602 755-9528 Trevor Bates 2 HP Laser Toner 805 851-0155 805 851-0155
CS251: Fundamentals of Database Systems 18 2. We have just updated our prices and need to print a current price list. This is a simple query that uses only the Product table and the description and price columns. It is sorted in ascending order by price. SQL Statement SELECT tbl_product.product_description, tbl_product.unit_price FROM tbl_product ORDER BY tbl_product.unit_price; qry_pricelist Product_Description Unit_Price Bic Pens - Black Fine $2.95 Bic Pens - Red Medium $2.95 Bic Pens - Black Medium $2.95 Dell Mouse $5.00 GP Copy Paper $5.45 CD - 100 pack $7.95 USB Cable $12.00 3GB SD Card $17.00 HP Premium Photopaper $27.95 Dell Speakers $29.00 HP Laser Toner $37.00
CS251: Fundamentals of Database Systems 19 3. Our company will be mailing out letters to our VIP Business members to invite them to an exclusive sale. This query will use the customer table, discount code table, mailing address table, and state table to find and order all customers with a VIP Business membership. SQL Statement: SELECT tbl_customer.company_name, tbl_customer.first_name, tbl_customer.last_name, tbl_mailing_address.street_address, tbl_mailing_address.address_2, tbl_mailing_address.city, tbl_mailing_address.state, tbl_mailing_address.zip FROM tbl_states INNER JOIN (tbl_mailing_address INNER JOIN (tbl_discount_code INNER JOIN tbl_customer ON tbl_discount_code.discount_code_id = tbl_customer.discount_code) ON tbl_mailing_address.mailing_address_id = tbl_customer.mailing_address) ON tbl_states.state_id = tbl_mailing_address.state WHERE (((tbl_discount_code.discount_code)="vip Business")) ORDER BY tbl_customer.company_name; qry_vipbusiness Company_Name First_Name Last_Name Street_Address Address_2 City State Zip ABC Computing John Elliot 123 St Paul Way 105 St Paul MN 12345 Bank One Zach Johnson PO Box 12777 Minneapolis MN 54321 Swasey Jewelers Trisha Swasey PO Box 14758-620 Los Angeles CA 97503
CS251: Fundamentals of Database Systems 20 The Microsoft Access database application (Week 5 IP) Forms Customer Input Form Employee Input Form
CS251: Fundamentals of Database Systems 21 Invoice Product Input Form Reports VIP Business Members Report HP Product Recall March 2011 Report
CS251: Fundamentals of Database Systems 22 Menus Main Menu Input Data Forms Menu Report Menu
CS251: Fundamentals of Database Systems 23 References Conceptual, Logical, and Physical Data Models. (2011). 1keydata.com. Retrieved from http://www.1keydata.com/datawarehousing/data-modeling-levels.html Fisher, S. (2011, February 15). Live Chat 2 Fundamentals of DB. CS251-1101B-05. Colorado Technical University Online. Hernandez, M. (2003). Database design for mere mortals (2 nd Edition). Addison-Wesley.