BA Lecture 4 - Transaction Processing Schemas

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Module 01 – Session 4

Data Models for


OLTP and OLAP

Business Analytics By : Prof. Subhasish Mitra


Data Models for OLTP
ER Model

• ER Model = Entity Relationship Model


• Adopted by OLTP systems
• Used to define data elements and relationships
between entities for a specified system
• Graphical approach to database design
• Develops a conceptual design for the database
• Develops a very simple and easy to design view of the
data
• Uses Entity/Relationship to represent real world
objects
Business Analytics By : Prof. Subhasish Mitra
ER Model

• Entity = thing or object in real world that is


distinguishable from surrounding environment.
• For example, each individual employee of an
organization is a separate entity
• An entity has a set of properties
• Entity properties can have values

Business Analytics By : Prof. Subhasish Mitra


ER Model

• ‘A’, an employee at XYZ can have attributes (properties)


such as name, age, weight, height etc.
• Each attribute can have Values
• Single attributes have one value (Age), but attributes
can have multiple values also (Phone number).
• Entities can have relationships with each other; for
example between ‘A’ and his PC

Business Analytics By : Prof. Subhasish Mitra


Why use ER Models?

• Designers, developers and end-users tend to view data


and its usage differently
• Can produce database systems that do not meet the
requirements of the users
• Hence we require communications tools that can be
understood by all stakeholders
• ER is one such tool
• ER diagrams also increase user productivity as they can
be easily translated into relational tables

Business Analytics By : Prof. Subhasish Mitra


ER Model - Example

• Suppose we design a school database


• Student will be an entity with attributes like:
• Address, name, ID, age etc.
• Address can be another entity with attributes like
house/building number/name, street name, city, pin
code etc.
• There will be a relationship between them

Business Analytics By : Prof. Subhasish Mitra


Components of ER Diagram

ER Model

Entity Attribute Relation


Weak Entity Key Attribute One-to-one

Composite
One-to-many
Attribute
Multi-valued
Many-to-one
Attribute
Derived
Many-to-many
Attribute

Business Analytics By : Prof. Subhasish Mitra


Components of ER Diagram

• Entity: represented as rectangles


Works
Employee for
Department

• Weak entity:
• that depends on another entity;
• doesn’t have any key attribute of its own;
• Represented by a double rectangle

Loan Installment

Business Analytics By : Prof. Subhasish Mitra


Components of ER Diagram

• Attribute: used to describe the property of an entity


• Represented by an ellipse

Name ID

Student

Phone
No.
Age

• Key Attribute: used to represent main characteristics

Business Analytics By : Prof. Subhasish Mitra


Components of ER Diagram

• Composite Attribute: composed of many other


attributes
• Represented by an ellipse connected with another
Name

First Middle Last


Name Name Name

• Multi-valued Attribute: have more than one value


• Represented by double ellipse
Business Analytics By : Prof. Subhasish Mitra
Components of ER Diagram

• Derived Attribute: can be obtained from another


attribute, e.g., age from date of birth
• Represented by dashed ellipse
Date of
Name Birth

Student

Phone
No.
Age

Business Analytics By : Prof. Subhasish Mitra


Components of ER Diagram

• Relationship: Represented by diamond

1 1
Works
Employee for
Department

1 M
Department Has Employee

• What is the relationship between “student” and


“books to be issued” in a library?

Business Analytics By : Prof. Subhasish Mitra


ER Diagram: Example

Business Analytics By : Prof. Subhasish Mitra


Data Models for OLAP
Data Models for OLAP

• Facts
• Numerical measures by which we want to analyze the
relationships between dimensions
• Total (sales in Rs.), Quantity (units sold), Discounts (in Rs.)
• Dimensions
• An entity with respect to which an organization wants to
keep records
• A department store might want to keep records of the store
sales with respect to “time”, “customer”, “product”,
“employee”
• Each dimension has an associated dimension table

Business Analytics By : Prof. Subhasish Mitra


Star Schema

Business Analytics By : Prof. Subhasish Mitra


Star Schema

• A central fact table


• Connected to 4 dimensions
• Each dimension is represented with a one-dimension
table
• Dimension table contains set of attributes
• Dimension tables are not joined to each other
• Optimized for querying large data sets

Business Analytics By : Prof. Subhasish Mitra


Snowflake Schema

Business Analytics By : Prof. Subhasish Mitra


Snowflake Schema

• Extension of star schema


• A central fact table connected to 4 dimensions
• Some dimensions are further normalized
• Uses smaller disk space
• Normalization of the dimension tables helps in
reducing redundancy, but slows down performance
• More look up tables implies more maintenance

Business Analytics By : Prof. Subhasish Mitra


Star vs. Snowflake
Star Schema Snowflake Schema
Contains a fact table One fact table surrounded by dimension
surrounded by dimension tables table, which in turn are surrounded by
dimension tables
Only a single join creates Requires many joins to fetch data
relationship
Simple DB design Complex DB design
De-normalized data structure Normalized data structure
High level of data redundancy Low level of data redundancy
Single dimension table Data split into different Dimension tables

Business Analytics By : Prof. Subhasish Mitra


Note

• When dimension table is relatively big in size, use


Snowflake schema as it reduces space
• When dimension table contains less number of rows,
go for Star schema

Business Analytics By : Prof. Subhasish Mitra

You might also like