You are on page 1of 70

ITD 256

Database Concepts

Lecture 03

Agenda

Functional Dependency
Normalization
Class Exercise
Recap HW2
Project Discussion
Database Processing
Business Intelligence Systems
Datawarehouses and Datamarts
Dimensional Databases
Class Exercise
Test Discussion
Quiz

Agenda

Functional Dependency
Normalization
Class Exercise
Recap HW2
Project Discussion
Database Processing
Business Intelligence Systems
Datawarehouses and Datamarts
Dimensional Databases
Class Exercise
Test Discussion
Quiz

Functional Dependencies
EMPLOYEE relation

EMPLOYEE (EmployeeNumber, FirstName, LastName, Department, Email, Phone)

Functional Dependency is the determination of values of one more columns if


value of another column is already known

Identify the Functional Dependencies

Functional Dependencies
EMPLOYEE relation

EMPLOYEE (EmployeeNumber, FirstName, LastName, Department, Email, Phone)

EmployeeNumber -> (FirstName, LastName, Department, Email, Phone)

Functional Dependencies
EMPLOYEE relation

EMPLOYEE (EmployeeNumber, FirstName, LastName, Department, Email, Phone)

EmployeeNumber -> (FirstName, LastName, Department, Email, Phone)

Email -> (EmployeeNumber, FirstName, LastName, Department, Phone)

Functional Dependencies
EMPLOYEE relation

EMPLOYEE (EmployeeNumber, FirstName, LastName, Department, Email, Phone)

EmployeeNumber -> (FirstName, LastName, Department, Email, Phone)

Email -> (EmployeeNumber, FirstName, LastName, Department, Phone)


Department -> Phone

Agenda

Functional Dependency
Normalization
Class Exercise
Recap HW2
Project Discussion
Database Processing
Business Intelligence Systems
Datawarehouses and Datamarts
Dimensional Databases
Class Exercise
Test Discussion
Quiz

Normalization
Normalization is Process of breaking table with more than one
theme into single themed tables based on functional dependencies
Follow two principles to call a table well-formed
For a well-formed relation, every Determinant must be a Candidate key
If not well-formed, break relation into two or more well-formed relations

Any relation that has following 8 characteristics is in 1NF


Normalized relations
are in 2NF & 3NF

Normalization Process
1. Identify all Candidate keys in the relation
2. Identify all functional dependencies in the relation
3. Examine determinants , if it is not a candidate then
a. Place columns of functional dependency in a new relation
b. Make determinant PRIMARY key of new relation
c. Leave a copy of determinant as foreign key in original relation
d. Write referential integrity constraint between original & new
relation
4. Draw the Normalized tables

Normalization Process

Sample data for PRESCRIPTION table

1. Identify all Candidate keys in the relation

1.
PRESCRIPTION (PrescriptionNumber, Date, Drug, Dosage, CustomerName,
CustomerPhone, CustomerEmail)

1.PRSECRIPTION (PrescriptionNumber, Date, Drug, Dosage, CustomerName,


CustomerPhone, CustomerEmail)

2. Identify all functional dependencies in the relation


2.
PrescriptionNumber -> (Date, Drug, Dosage, CustomerName, CustomerPhone,
CustomerEmail)

1.PRESCRIPTION (PrescriptionNumber, Date, Drug, Dosage, CustomerName,


CustomerPhone, CustomerEmail)

2. Identify all functional dependencies in the relation


2.
PrescriptionNumber -> (Date, Drug, Dosage, CustomerName, CustomerPhone,
CustomerEmail)
CustomerEmail -> (CustomerName, CustomerPhone)

1.PRESCRIPTION (PrescriptionNumber, Date, Drug, Dosage, CustomerName,


CustomerPhone, CustomerEmail)
2. PrescriptionNumber -> (Date, Drug, Dosage, CustomerName, CustomerPhone,
CustomerEmail)
CustomerEmail -> (CustomerName, CustomerPhone)
3. Examine determinants , if it is not a candidate then
a. Place columns of functional dependency in a new relation

3.
a. CUSTOMER (CustomerName, CustomerPhone, CustomerEmail)

1.PRESCRIPTION (PrescriptionNumber, Date, Drug, Dosage, CustomerName,


CustomerPhone, CustomerEmail)
2. PrescriptionNumber -> (Date, Drug, Dosage, CustomerName, CustomerPhone,
CustomerEmail)
CustomerEmail -> (CustomerName, CustomerPhone)
3. Examine determinants , if it is not a candidate then
a. Place columns of functional dependency in a new relation
b. Make determinant PRIMARY key

3.
a. CUSTOMER (CustomerName, CustomerPhone, CustomerEmail)
b. CUSTOMER (CustomerName, CustomerPhone, CustomerEmail)

1.PRESCRIPTION (PrescriptionNumber, Date, Drug, Dosage, CustomerName,


CustomerPhone, CustomerEmail)
2. PrescriptionNumber -> (Date, Drug, Dosage, CustomerName, CustomerPhone,
CustomerEmail)
CustomerEmail -> (CustomerName, CustomerPhone)
3. Examine determinants , if it is not a candidate then
a. Place columns of functional dependency in a new relation
b. Make determinant PRIMARY key
c. Leave a copy of determinant as foreign key in original relation

3.
a. CUSTOMER (CustomerName, CustomerPhone, CustomerEmail)
b. CUSTOMER (CustomerName, CustomerPhone, CustomerEmail)
c. PRESCRIPTION (PrescriptionNumber, Date, Drug, Dosage, CustomerEmail)

1.PRESCRIPTION (PrescriptionNumber, Date, Drug, Dosage, CustomerName,


CustomerPhone, CustomerEmail)
2. PrescriptionNumber -> (Date, Drug, Dosage, CustomerName, CustomerPhone,
CustomerEmail)
CustomerEmail -> (CustomerName, CustomerPhone)
3. Examine determinants , if it is not a candidate then
a. Place columns of functional dependency in a new relation
b. Make determinant PRIMARY key
c. Leave a copy of determinant as foreign key in original relation
d. Create referential integrity constraint between original & new relation

3.
a. CUSTOMER (CustomerName, CustomerPhone, CustomerEmail)
b. CUSTOMER (CustomerName, CustomerPhone, CustomerEmail)
c. PRESCRIPTION (PrescriptionNumber , Date, Drug, Dosage, CustomerEmail)
d. CustomerEmail in PRESCRIPTION must exist in CustomerEmail in CUSTOMER

1.PRESCRIPTION (PrescriptionNumber, Date, Drug, Dosage, CustomerName,


CustomerPhone, CustomerEmail)
2. PrescriptionNumber -> (Date, Drug, Dosage, CustomerName, CustomerPhone,
CustomerEmail)
CustomerEmail -> (CustomerName, CustomerPhone)

3.
a. CUSTOMER (CustomerName, CustomerPhone, CustomerEmail)
b. CUSTOMER (CustomerName, CustomerPhone, CustomerEmail)
c. PRESCRIPTION (PrescriptionNumber , Date, Drug, Dosage, CustomerEmail)
d. CustomerEmail in PRESCRIPTION must exist in CustomerEmail in CUSTOMER

1.PRESCRIPTION (PrescriptionNumber, Date, Drug, Dosage, CustomerName,


CustomerPhone, CustomerEmail)
2. PrescriptionNumber -> (Date, Drug, Dosage, CustomerName, CustomerPhone,
CustomerEmail)
CustomerEmail -> (CustomerName, CustomerPhone)
3. a. CUSTOMER (CustomerName, CustomerPhone, CustomerEmail)
b. CUSTOMER (CustomerName, CustomerPhone, CustomerEmail)
c. PRESCRIPTION (PrescriptionNumber , Date, Drug, Dosage, CustomerEmail)
d. CustomerEmail in PRESCRIPTION must exist in CustomerEmail in CUSTOMER

Normalization Example 2

Sample data for STU_DORM

1. STU_DORM (StudentNumber, LastName, FirstName, DormName, DormCost)

1. STU_DORM (StudentNumber, LastName, FirstName, DormName, DormCost)


2. StudentNumber -> (LastName, FirstName, DormName, DormCost)

1. STU_DORM (StudentNumber, LastName, FirstName, DormName, DormCost)


2. StudentNumber -> (LastName, FirstName, DormName, DormCost)
DormName -> DormCost

1. STU_DORM (StudentNumber, LastName, FirstName, DormName, DormCost)


2. StudentNumber -> (LastName, FirstName, DormName, DormCost)
DormName -> DormCost
3.
a. DORM (DormName, DormCost)

1. STU_DORM (StudentNumber, LastName, FirstName, DormName, DormCost)


2. StudentNumber -> (LastName, FirstName, DormName, DormCost)
DormName -> DormCost
3.
a. DORM (DormName, DormCost)
b. DORM (DormName, DormCost)

1. STU_DORM (StudentNumber, LastName, FirstName, DormName, DormCost)


2. StudentNumber -> (LastName, FirstName, DormName, DormCost)
DormName -> DormCost
3.
a. DORM (DormName, DormCost)
b. DORM (DormName, DormCost)
c. STU_DORM (StudentNumber, LastName, FirstName, DormName )

1. STU_DORM (StudentNumber, LastName, FirstName, DormName, DormCost)


2. StudentNumber -> (LastName, FirstName, DormName, DormCost)
DormName -> DormCost
3.
a. DORM (DormName, DormCost)
b. DORM (DormName, DormCost)
c. STU_DORM (StudentNumber, LastName, FirstName, DormName )
d. DormName in STU_DORM must exist in DormName in DORM

1. STU_DORM (StudentNumber, LastName, FirstName, DormName, DormCost)


2. StudentNumber -> (LastName, FirstName, DormName, DormCost)
DormName -> DormCost
3.
a. DORM (DormName, DormCost)
b. DORM (DormName, DormCost)
c. STU_DORM (StudentNumber, LastName, FirstName, DormName )
d. DormName in STU_DORM must exist in DormName in DORM

Normalization Example 3

Sample data for EMPLOYEE

1. EMPLOYEE (EmployeeNumber, LastName, Department, Email, DeptPhone)

1. EMPLOYEE (EmployeeNumber, LastName, Department, Email, DeptPhone)


2. EmployeeNumber -> (LastName, Department, Email, DeptPhone)

1. EMPLOYEE (EmployeeNumber, LastName, Department, Email, DeptPhone)


2. EmployeeNumber -> (LastName, Department, Email, DeptPhone)
Email -> (EmployeeNumber, LastName, Department, DeptPhone)

1. EMPLOYEE (EmployeeNumber, LastName, Department, Email, DeptPhone)


2. EmployeeNumber -> (LastName, Department, Email, DeptPhone)
Email -> (EmployeeNumber, LastName, Department, DeptPhone)
Department -> DeptPhone

1. EMPLOYEE (EmployeeNumber, LastName, Department, Email, DeptPhone)


2. EmployeeNumber -> (LastName, Department, Email, DeptPhone)
Email -> (EmployeeNumber, LastName, Department, DeptPhone)
Department -> DeptPhone
3.
a. DEPARTMENT (Department, DeptPhone)

1. EMPLOYEE (EmployeeNumber, LastName, Department, Email, DeptPhone)


2. EmployeeNumber -> (LastName, Department, Email, DeptPhone)
Email -> (EmployeeNumber, LastName, Department, DeptPhone)
Department -> DeptPhone
3.
a. DEPARTMENT (Department, DeptPhone)
b. DEPARTMENT (Department, DeptPhone)

1. EMPLOYEE (EmployeeNumber, LastName, Department, Email, DeptPhone)


2. EmployeeNumber -> (LastName, Department, Email, DeptPhone)
Email -> (EmployeeNumber, LastName, Department, DeptPhone)
Department -> DeptPhone
3.
a. DEPARTMENT (Department, DeptPhone)
b. DEPARTMENT (Department, DeptPhone)
c. EMPLOYEE (EmployeeNumber, LastName, Department, Email)

1. EMPLOYEE (EmployeeNumber, LastName, Department, Email, DeptPhone)


2. EmployeeNumber -> (LastName, Department, Email, DeptPhone)
Email -> (EmployeeNumber, LastName, Department, DeptPhone)
Department -> DeptPhone
3.
a. DEPARTMENT (Department, DeptPhone)
b. DEPARTMENT (Department, DeptPhone)
c. EMPLOYEE (EmployeeNumber, LastName, Department, Email)
d. Department in EMPLOYEE must exist in Department in DEPARTMENT

1. EMPLOYEE (EmployeeNumber, LastName, Department, Email, DeptPhone)


2. EmployeeNumber -> (LastName, Department, Email, DeptPhone)
Email -> (EmployeeNumber, LastName, Department, DeptPhone)
Department -> DeptPhone
3.
a. DEPARTMENT (Department, DeptPhone)
b. DEPARTMENT (Department, DeptPhone)
c. EMPLOYEE (EmployeeNumber, LastName, Department, Email)
d. Department in EMPLOYEE must exist in Department in DEPARTMENT

Agenda

Functional Dependency
Normalization
Class Exercise
Recap HW2
Project Discussion
Database Processing
Business Intelligence Systems
Datawarehouses and Datamarts
Dimensional Databases
Class Exercise
Test Discussion
Quiz

Class Exercise
Explain the meaning of the following expression.
A (B, C)
Given this expression, tell if it is also true that:
A B and A C
Explain the meaning of the following expression:
(D, E) F
Given this expression, tell if it is also true that:
D F and E F

Normalization process is based on ________________________________.

Agenda

Functional Dependency
Normalization
Class Exercise
Recap HW2
Project Discussion
Database Processing
Business Intelligence Systems
Datawarehouses and Datamarts
Dimensional Databases
Class Exercise
Test Discussion
Quiz

HW 2
1. Explain the difference between a primary key and a candidate key. (2pts)
2. What is a surrogate key and why would you use one? (2pt)
3. Explain the term foreign key. (2pt)
4. Define the term referential integrity constraint. (2pts)
5. Define the terms functional dependency and determinant. (2pts)
6. Define the term primary key in terms of functional dependencies. (2pts)
7. Draw Relations Equivalent set of terms for Table, Row, and Column. (2pts)
8. In your own words, describe the purpose of the normalization process. (2pts)

9. Apply the normalization process to figure above to develop a set of normalized


relations (assume PetName is unique in the relation above). Show the results of
each of the steps in the normalization process 1,2,3a,3b,3c,3d. (5pts)
10. Draw and populate the two normalized tables from Q9. (4pts)

Agenda

Functional Dependency
Normalization
Class Exercise
Recap HW2
Project Discussion
Database Processing
Business Intelligence Systems
Datawarehouses and Datamarts
Dimensional Databases
Class Exercise
Test Discussion
Quiz

Agenda

Functional Dependency
Normalization
Class Exercise
Recap HW2
Project Discussion
Database Processing
Business Intelligence Systems
Datawarehouses and Datamarts
Dimensional Databases
Class Exercise
Test Discussion
Quiz

Database Processing

Database Processing
Stored Procedures
Stored Procedure is like a computer program stored
within the database
Any SQL code to make changes to the database can be
executed from a stored procedure
Application programs, web applications and query users can
invoke stored procedures
Parameters can be passed to stored procedure to perform
action or receive results

Database Processing
Triggers
Trigger is program stored within database that is
executed when specific event occurs
The events are typically INSERTS, UPDATES, or DELETES
The events are handled BEFORE, AFTER, or INSTEAD OF trigger
logic
Action code can be written or Stored Procedures can be called
as a trigger response

Web Database Processing

Web Database Processing

Standard Interfaces developed for accessing


databases
OLEDB
ADO.NET
ODBC

Web Database Processing

Hypertext Markup Language (HTML)


Most common web page standard

Hypertext means other objects are included


(pictures, audio, video, maps, etc.)

Web Database Processing

Extensible Markup Language (XML)


Common way of defining document structure and
transmitting them between computers
Standard means of submitting & receiving data from
the database(s) in web development environment

Agenda

Functional Dependency
Normalization
Class Exercise
Recap HW2
Project Discussion
Database Processing
Business Intelligence Systems
Datawarehouses and Datamarts
Dimensional Databases
Class Exercise
Test Discussion
Quiz

Business Intelligence Systems


Business Intelligence (BI) systems are also called Decision
Support (DSS) systems

BI assist Management in analysis of past/current activities and


prediction of future events
BI systems support management assessment, analysis, planning,
control, and decision making.
Note - BI systems do not support operation activities, only
analyze the data

Business Intelligence Systems


BI application need to read & process from Operational Data
Querying Data for BI applications is resources intensive
Operational data is limited for BI use, so they need to be separate
Therefore large organizations extract separate BI databases from
operational databases
BI systems use Data Dictionary which is reference repository containing
metadata

Business Intelligence Systems


Operational Systems: Online Transaction Processing (OLTP)
BI System: OLAP (Online Analytical Processing)

Agenda

Functional Dependency
Normalization
Class Exercise
Recap HW2
Project Discussion
Database Processing
Business Intelligence Systems
Datawarehouses and Datamarts
Dimensional Databases
Class Exercise
Test Discussion
Quiz

Data Warehouses

Data Marts
Data Mart is a collection of data that is smaller than
data warehouse and addresses a particular component
of business
Users of data mart are knowledgeable analysts of that
business function

Data Marts

Agenda

Functional Dependency
Normalization
Class Exercise
Recap HW2
Project Discussion
Database Processing
Business Intelligence Systems
Datawarehouses and Datamarts
Dimensional Databases
Class Exercise
Test Discussion
Quiz

Dimensional Databases
Databases in data warehouse or data mart are built to different
database design (not normalized relational design) called
dimensional database.
Dimensional Databases are designed for efficient data queries
and analysis

Dimensional Databases
Star Schema is a data warehouse modeling technique used to
represent the multi-dimensional data in fact and dimension tables

Agenda

Functional Dependency
Normalization
Class Exercise
Recap HW2
Project Discussion
Database Processing
Business Intelligence Systems
Datawarehouses and Datamarts
Dimensional Databases
Class Exercise
Test Discussion
Quiz

Class Exercise
Business Intelligence (BI) systems do which of the following?
A) Analyze current and past activities
B) Predict future events for strategic advantage
C) Record and process transactions
D) Both A and B
E) All of the above

Business Intelligence (BI) systems fall into which of the following categories?
A) Processing
B) Reporting
C) Decision Support
D) Both A and B
E) Both B and C

Class Exercise
Star Schema is used to graphically represent what kind of data?
A) Operational
B) Missing
C) Multi-dimensional
D) Both A and B
E) None of the above

A particular component of business data subset of the datawarehouse?


A) ERD
B) OLAP
C) ODBC
D) DataMart
E) Data Dictionary

Class Exercise
Data Dictionary is a reference repository containing
A) User data
B) Metadata
C) SQL code
D) Both A and B
E) None of the above

In web processing environment XML provide a way for documents to be


A) Displayed
B) Removed
C) Transmitted
D) Altered
E) None of the above

Agenda

Functional Dependency
Normalization
Class Exercise
Recap HW2
Project Discussion
Database Processing
Business Intelligence Systems
Datawarehouses and Datamarts
Dimensional Databases
Class Exercise
Test Discussion
Quiz

Test Discussion
Test 1 Lecture 01, Lecture 02 & Lecture 03 (150pts)
10 multiple choice questions from Relational Databases
(3pts each = 30pts)

5 questions related to Relational Databases


(3pts each = 15pts)

4 Questions regarding 3rd normal form to write schema


(10pts each = 40pts)

1 Normalize a 2-themed list showing steps 1,2,3abcd & 4


(25pts)

10 multiple choice questions from BI Systems


(4pts each = 40pts)

Agenda

Functional Dependency
Normalization
Class Exercise
Recap HW2
Project Discussion
Database Processing
Business Intelligence Systems
Datawarehouses and Datamarts
Dimensional Databases
Class Exercise
Test Discussion
Quiz

You might also like