ISQS 6339, Business Intelligence Database vs. Data Warehouse Zhangxi Lin Texas Tech University 1 1
Agenda Install Parallels (instructions) Test SQL Server 2016 on Parallels Access the shared network drive For MacBook: http://zlin.ba.ttu.edu/3358/MacBookMapping.htm For Windows: Map to \\Techshare\coba\d\isqs3358 Create a database using WPC scripts \\Techshare\coba\d\isqs3358\isqs3348\Exercises\D BC-e07-WPC-Scripts Convert WPC database to data warehouse
Database Review ISQS6339
Purpose of a Database The purpose of a database is to keep track of things. Unlike a list or spreadsheet, a database may store information that is more complicated than a simple list. KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall
Components of a Database System Figure 1-15: Components of a Database System KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall
Relational Databases A relational database stores information in tables. Each informational topic is stored in its own table. In essence, a relational database will break-up a list into several parts—one part for each theme in the list. A Project List would be divided into a CUSTOMER Table, a PROJECT Table, and a PROJECT_MANAGER Table. KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall
Example Database Metadata: A Relationship Diagram Figure 1:16 Example Metadata: A Relationship Diagram for the Art Course Tables in Figure 1-10 KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall
Normalization Process Identify all the candidate keys of the relation Identify all the functional dependencies in the relation Examine the determinants of the functional dependencies. If any determinant is not a candidate key, the relation is not well formed. Place the columns of the functional dependency in a new relation of their own Make the determinant of the functional dependency the primary key of the new relation. Leave a copy of the determinant as a foreign key in the original relation. Create a referential integrity constraint between the original relation and the new relation. Repeat Step 3 as many times as necessary until every determinant of every relation is a candidate key KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall
Normal Forms There are many defined normal forms: First Normal Form (1NF) Second Normal Form (2NF) Third Normal Form (3NF) Boyce-Codd Normal Form (BCNF) Fourth Normal Form (4NF) Fifth Normal Form (5NF) Domain/Key Normal Form (DK/NF) KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall
This is Boyce-Codd Normal Form (BCNF) Normalization to BCNF For our purposes, a relation is considered normalized when: Every determinant is a candidate key. This is Boyce-Codd Normal Form (BCNF) KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall
Normalization Example (StudentID) (StudentName, DormName, DormCost) However, if… (DormName) (DormCost) Then DormCost should be placed into its own relation, resulting in the relations: (StudentName, DormName) (StudentID) (DormName) (DormCost) KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall
Normalization Example (Cont’d) (AttorneyID,ClientID) (ClientName, MeetingDate, Duration) However, if… (ClientID) (ClientName) Then ClientName should be placed into its own relation, resulting in the relations: (AttorneyID,ClientID) (MeetingDate, Duration) (ClientName) (ClientID) KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Educations, Inc. Publishing as Prentice Hall
Levels of Entity Attribute Display Figure 4-3: Levels of Entity Attribute Display KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall
Relationships Entities can be associated with one another in relationships. Relationship degree defines the number of entity classes participating in the relationship: Degree 2 is a binary relationship. Degree 3 is a ternary relationship. KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall
Crow’s Foot Symbols Figure 4-8: Crow’s Foot Notation KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall
Crow’s Foot Example: One-to-Many Relationship Figure 4-7: Two Versions of a 1:N Relationship KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall
Heather Sweeney Designs: Final Data Model (c) The Finished Data Model Figure 4-21: The Final Data Model for Heather Sweeney Designs KROENKE and AUER - DATABASE CONCEPTS (7th Edition) Copyright © 2015 Pearson Education, Inc. Publishing as Prentice Hall
Database case Find the SQL scripts in \\Techshare\coba\d\isqs3358\isqs3348\Exercises\ Use the scripts in \DBC-e07-WPC Script\ Download file http://zlin.ba.ttu.edu/3358/WPCExercises.docx for the exercises
Wedgewood Pacific Corporation
Wedgewood Pacific Corporation
Incapability of database How could I analyze the performance between departments regarding workload and employee numbers? How could I do online prediction of future projects trend according to current projects? If the database contains 100 million records how could the response time become acceptable?
Data warehousing
Data Mart Planning Fact table – collections of measures Measures: MaxHours, HoursWorked Dimension tables Time: StartDate, EndDate Project Employee Department
Dimensional Model DIM_PROJECT ---------------------- DIM_DEPSRTMENT ProjectID ProjectName Department MaxHours StartDate EndDate …… DIM_DEPSRTMENT --------------------------- DepartmentName BudgetCode OfficeNumber Phone PROJ_ASSIGN ---------------------- EmployeeNumber ProjectID HoursWorked StartDate EndDate DIM_EMPLOYEE ------------------------ EmployeeNumber FirstName LastName Department Phone Email DIM_TIME --------------- Year Quarter Month Week Date
Data Mart Design Fact Table Dimension Tables PROJ_ASSIGN (ProjectID, EmployeeNumber, HoursWorked, StartDate, EndDate) Dimension Tables TIME(Year-Quarter-Month-Date) PROJECT(ProjectID, ProjectName, Department, MaxHours) DEPARTMENT(DepartmentName, BudgetCode, OfficeNumber, Phone) EMPLOYEE(EmployeeNumber, FirstName, LastName, Department, Phone, Email)
Data Mart Design – Scheme 2 Fact Table PROJect (ProjectID, ProjectName, Department, MaxHours, StartDate, EndDate) Dimension Tables TIME(Year-Quarter-Month-Date) DEPARTMENT(DepartmentName, BudgetCode, OfficeNumber, Phone) This is a simplified model from the previous