0% found this document useful (0 votes)
5 views36 pages

Understanding Data Types in Analytics and Programming

Chapter 3 discusses various data types used in analytics and programming, categorizing analytic data into descriptive, diagnostic, predictive, and prescriptive types. It also outlines programming data types, including primitive, composite, and user-defined types, along with their features and examples. Additionally, the chapter explains type casting, detailing implicit and explicit conversions between data types.

Uploaded by

omarkamrl1234
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views36 pages

Understanding Data Types in Analytics and Programming

Chapter 3 discusses various data types used in analytics and programming, categorizing analytic data into descriptive, diagnostic, predictive, and prescriptive types. It also outlines programming data types, including primitive, composite, and user-defined types, along with their features and examples. Additionally, the chapter explains type casting, detailing implicit and explicit conversions between data types.

Uploaded by

omarkamrl1234
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CHAPTER 3: DATA TYPES Dr: El-Sayed Orabi

1. Analytic Data Types

Topics 2. Data types

3. Programing data types


1. Analytic Data Types
Data analytics can be broadly categorized into four
types: descriptive, diagnostic, predictive, and prescriptive. These
types represent different stages of data analysis and offer
varying levels of insight into past, present, and future trends
1.1 Descriptive Analytics

Main Features: Summarizes past/historical data; answers 'What


happened?'

Usage: Reporting, dashboards, identifying trends and patterns

Example: Monthly sales dashboard for the past year


1.2 Diagnostic Analytics

Main Features: Usage: Root cause Example:


Investigates data analysis, Analyzing reasons
to explain 'Why comparison across for a drop in sales
did it happen?' segments in a specific region
1.3 Predictive Analytics

Main Features: Uses Usage: Risk Example: Predicting


statistical models and prediction, demand customer churn based
ML to forecast; forecasting, customer on historical purchase
answers 'What is behavior analysis patterns
likely to happen?'
1.4 Prescriptive Analytics

Main Features: Recommends optimal decisions; answers 'What


should we do?'

Usage: Optimization, strategic planning, resource allocation

Example: Suggesting best delivery routes for cost and time


efficiency
1. Categorical (Nominal) Data

2. Ordinal Data

3. Interval Data
2. Data types
4. Ratio Data

5. Special Ordinal (Likert-Type)


Data
2.1 Categorical (Nominal) Data

Main Features: Usage: Example:


Named Classification, Gender, Eye
categories with labeling. Color, Marital
no inherent order. Status
2.2 Ordinal Data

Main Features: Example: Education


Categories with a Usage: Rankings, Level, Satisfaction
meaningful order but levels of satisfaction. Rating
unequal intervals.
2.3 Interval Data

Main features: numeric data Usage: measuring Example: temperature in


with equal intervals, no true temperature, test scores. celsius, IQ scores
zero.
2.4 Ratio Data

Main Features: Usage: Physical Example: Height,


Numeric data with and financial Weight, Income,
equal intervals measurements. Age
and a true zero.
2.5 Special Ordinal (Likert-Type) Data

Main Features: Ordered survey scales, often treated as interval


data.

Usage: Measuring attitudes, perceptions.

Example: 'Strongly disagree' to 'Strongly agree' survey scale


1. Primitive data types

3. Programing 2. Composite data types


Data types

3. User define data types


3.1 Primitive Data Types
Primitive data types are the most basic data types available in a
programming language. They represent simple, fundamental values and are
typically built into the language itself. Unlike complex data structures (like
objects or arrays), primitive types cannot be broken down into simpler
components.
3.1.1 Integer (int)
Main Features:
• Whole numbers (positive or negative)
• No decimals
Usage:
Counting, indexing, loops, arithmetic operations
Example:
int x = 10;
int age = -5;
3.1.2 Floating Point (float/double)
Main Features:
• Numbers with decimals
• Single or double precision
Usage:
Calculations involving fractions, measurements
Example:
float price = 9.99;
double distance = 45.67;
3.1.3 Character (char)
Main Features:
• Single Unicode character
• Enclosed in single quotes
Usage:
Letters, symbols, or controlling characters
Example:
char grade = 'A';
char symbol = '#';
3.1.4 Boolean
Main Features:
• Logical values: true or false
Usage:
Conditional logic, comparisons, control structures
Example:
•boolean isOnline = true;
•bool passed = false;
3.1.5 Date Data Type
Main Features:
Stores only the calendar date (year, month, day)
No time component
Format: typically YYYY-MM-DD
Usage:
Store birthdates, appointment dates, deadlines, etc.
Examples:
•SQL: DATE '2025-07-30’
•Python: date(2025, 7, 30)
•Java: [Link](2025, 7, 30)
3.1.6 Time Data Type
Main Features:
•Stores only the time of day (hours, minutes, seconds, optionally milliseconds)
•No date component
•Format: typically HH:MM:SS
Usage:
Store event start/end times, daily schedules, alarms
Examples:
•SQL: TIME '14:30:00’
•Python: time(14, 30, 0)
•Java: [Link](14, 30)
3.1.7 Datetime / Timestamp Data Type
Main Features:
•Combines both date and time
•Includes full calendar date and time of day
•Format: YYYY-MM-DD HH:MM:SS
Usage:
Store precise timestamps (e.g., login time, transaction time)
Examples:
•SQL: TIMESTAMP '2025-07-30 14:30:00’
•Python: datetime(2025, 7, 30, 14, 30, 0)
•Java: [Link](2025, 7, 30, 14, 30)
3.2 Composite Data Types
Composite data types, also known as structured or complex data types, are
data types in programming that are constructed by combining multiple
individual data elements, which can include primitive data types (like integers,
characters, Booleans, floats) or other composite data types, into a single,
cohesive unit. They allow for the representation of more complex data
structures and real-world entities than primitive types alone can achieve.
3.2.1 Array
Main Features:
• Collection of same data type
• Fixed size
• Accessed by index
Usage:
Store list of similar items like scores or prices
Example:
int scores[5] = {90, 85, 88, 92, 75};
scores = [90, 85, 88, 92, 75]
3.2.2 List (Dynamic Array)
Main Features:
• Ordered, dynamic size
• Mixed types allowed (e.g., in Python)
Usage:
Store ordered data with flexibility
Example:
items = [23, "apple", True]
3.2.3 Tuple
Main Features:
• Ordered, immutable
• Can store multiple data types
Usage:
Return multiple values; fixed structure
Example:
user = ("Alice", 25, "Engineer")
3.2.4 Dictionary / Map
Main Features:
• Key-value pairs
• Keys are unique
• Fast access by key
Usage:
Associate labels with values like name & age
Example:
person = {"name": "Alice", "age": 30}
3.2.5 Set
Main Features:
• Unordered collection
• Unique elements only
Usage:
Store non-duplicate items; perform set operations
Example:
unique_numbers = {1, 2, 3, 3} # Output: {1, 2, 3}
3.3 User-Defined Data Types (UDTs)
Main Features:
•Created by programmers to represent complex or custom data structures
•Built using primitive or composite data types
•Allow for modularity, reusability, and clearer code structure
•Common in Object-Oriented Programming (OOP) and strongly typed languages
Usage:
•Model real-world entities (e.g., Student, Book, Vehicle)
•Group related variables under one type
•Enable encapsulation (in OOP)
3.3.1 Structure (struct) – in C/C++
Usage: Groups student attributes under a single custom type.
Example:
struct Student {
char name[50];
int age;
float gpa;
};
3.3.2 Class – in Java/Python/C++
Usage: Combines data and behavior (methods); used for OOP design.
Example:
class Book:
def __init__(self, title, author, pages):
[Link] = title
[Link] = author
[Link] = pages
3.3.3 Enum – in C, Java, Python
Usage: Defines a set of named constants (e.g., days of the week, colors).
Example:
num Day { MONDAY, TUESDAY, WEDNESDAY };
3.3.4 Union – in C
Usage: Stores different data types in the same memory location (saves space).
Example:
union Data {
int intVal;
float floatVal;
char str[20];
};
3.4 Type Casting in Programming
Type Casting is the process of converting a variable from one data type to another,
either automatically or manually.
Main Features:
•Changes the data type of a value or variable
•Helps in memory management, arithmetic compatibility, or interfacing different
systems
•Can be implicit (automatic) or explicit (manual)
3.4.1 Implicit Type Casting
Main features:
•Automatically done by the compiler
•Converts a smaller data type to a larger one
No data loss
Example
int a = 10;
float b = a; // int to float automatically
3.4.2 Explicit Type Casting
Main features:
•Performed manually by the programmer
•Converts a larger data type to a smaller one
•May lead to data loss or truncation
Example:
float pi = 3.14;
int num = (int) pi; // result: 3

You might also like