0% found this document useful (0 votes)
22 views

Mysql

Uploaded by

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

Mysql

Uploaded by

febiba1449
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

MYSQL TECHNICAL PRESENTATION

Group No.1

Topic Data Types in MYSQL


GROUP MEMBERS

• Kishore Vadlamudi
• Poojitha
• Thomala Swathi
• Maheshwari Subbara
• Nakka Vivek Kumar
• Maneesha
• Sharath Kumar
• Ketan
• Anshika Rai
• Abhishek
WHAT IS MYSQL
•MYSQL IS AN OPEN-SOURCE RELATIONAL DATABASE MANAGEMENT SYSTEM (RDBMS) THAT
STORES DATA IN ROWS AND COLUMNS. IT'S USED IN MANY INDUSTRIES, INCLUDING WEB
APPLICATIONS, B2B SERVICES, AND CUSTOMER-FACING APPLICATIONS.

•OPEN SOURCE
•ANYONE CAN USE, MODIFY, PUBLISH, AND EXPAND ON MYSQL. IT'S RELEASED UNDER THE GNU
GENERAL PUBLIC LICENSE (GPL).
•RELATIONAL DATABASE
•MYSQL STORES DATA IN SEPARATE TABLES AND DEFINES RELATIONSHIPS BETWEEN ROWS AND
COLUMNS IN SCHEMAS.
•SPEED AND RELIABILITY
•MYSQL IS KNOWN FOR ITS SPEED AND RELIABILITY.
•WIDE COMPATIBILITY
•MYSQL IS AVAILABLE ON OVER 20 PLATFORMS, INCLUDING LINUX, UNIX, WINDOWS, AND MAC.
•USED BY TOP WEBSITES
•MYSQL IS THE RDBMS BEHIND MANY OF THE TOP WEBSITES IN THE WORLD, INCLUDING
FACEBOOK, TWITTER, AND YOUTUBE.
OVERVIEW OF MYSQL AND ITS DATA TYPES

• MySQL is a database management system that uses SQL to interact with its database and
supports a variety of data types. These data types are used to store and retrieve different types
of data efficiently

1.Numeric Data Types:


2.String (Character) Data
Types:
3.Date and Time Data
Types:
4.Spatial Data Types:
5.JSON Data Type:
6.Boolean Data Type:
Key Data Types:

INT VARCHAR: DECIMAL: FLOAT: DATE: TEXT:


(Integer):
NUMERIC DATA TYPES IN MYSQL
OVERVIEW OF NUMERIC TYPES
Floating-Point Types Decimal Type

• For storing decimal values, • The DECIMAL data type is


MySQL provides FLOAT and unique as it allows for exact
DOUBLE types. FLOAT offers precision in numeric values.
a 7-digit precision while This makes it particularly
DOUBLE provides up to 15 useful in storing financial data
digits. These types are ideal where rounding errors can
for scientific calculations have significant impacts. The
where precision is paramount. DECIMAL type can store up to
Knowing the right floating- 65 digits, making it versatile
point type can enhance for various applications.
performance and accuracy in
data processing.

Integer Types

• MySQL supports multiple integer types, including TINYINT, SMALLINT, MEDIUMINT, INT, and BIGINT. These
7
types differ in their storage size, range, and use cases. TINYINT is limited to 1 byte while BIGINT takes up 8
bytes. Understanding these differences helps in selecting the appropriate type for specific data needs.
Data Types Explained
Data Type Storage Size Value Range

TINYINT 1 byte -128 to 127

SMALLINT 2 bytes -32,768 to 32,767

MEDIUMINT 3 bytes -8,388,608 to 8,388,607

INT 4 bytes -2,147,483,648 to 2,147,483,647

-9,223,372,036,854,775,808 to
BIGINT 8 bytes
9,223,372,036,854,775,807

FLOAT 4 bytes -3.402823466E+38 to 3.402823466E+38

-1.7976931348623157E+308 to
DOUBLE 8 bytes
1.7976931348623157E+308

DECIMAL Varies Exact values with precision


8
CHOOSING THE RIGHT TYPE

Application Needs

Identify the specific needs of your application to tailor the numeric


type accordingly. For example, financial applications often require
DECIMAL for precision, while analytical systems might prefer
DOUBLE or FLOAT for flexibility. Understanding the requirements can
significantly impact data accuracy and application performance.

Performance Considerations

When selecting numeric types, consider the performance of your


queries. Smaller data types can lead to faster processing since
they occupy less memory. However, it’s essential to avoid under
sizing, as this could lead to data truncation or unexpected errors
9

during computations.
PRACTICAL USE CASES

Real-World Applications

• Numeric data types support a wide array of real-world applications. For instance, TINYINT is
often used for flags or small numbers, while DECIMAL is vital in finance for accurate
calculations. Similarly, FLOAT and DOUBLE are perfect for scientific data where precision and
range are essential. Understanding these use cases allows developers to utilize the most
efficient data types for their specific applications.
Fixed point data types store numerical
values with a fixed number of decimal
places.

This precision is crucial for accurate


FIXED POINT DATA TYPES calculations involving currency,
measurements, and other data where
decimal values are important.

Types:- DECIMAL, NUMERIC

Each offers different precision and scale capabilities,


depending on your specific database system and requirements.
DECIMAL:- STORES EXACT NUMERIC SIMILAR TO BOTH HAVE
DECIMAL VALUES DECIMAL, BUT PRECISION AND
WITH A DEFINED THE SCALE UP TO 38
PRECISION. IMPLEMENTATION DIGITS.
MIGHT VARY
BETWEEN
DATABASE
SYSTEMS.

Precision:- The total number of digits (both before and after the decimal point).

Scale:- The number of digits to the right of the decimal point.

Ex:- 1.234
Precision = 4
Scale = 3
DATE AND TIME DATA TYPES IN SQL

•DATE: Stores date values in the format YYYY-MM-DD.

•TIME: Stores time values in the format HH:MM:SS.

•DATETIME: Combines date and time in the format


YYYY-MM-DD HH:MM:SS.

•TIMESTAMP: Stores date and time, typically in


UTC(Coordinated Universal Time), often auto-
generated or updated on row changes.
IN MYSQL, DATE, DATETIME, AND TIMESTAMP
DATA TYPES ARE:
Range of values: The DATE
data type stores only the date,
while the DATETIME
and TIMESTAMP data types
DATE: Stores dates from
store both the date and
1000-01-01 to 9999-12-31
time. The DATETIME data type
has a wider range of dates
than the TIMESTAMP data
type:

DATETIME: Stores dates TIMESTAMP: Stores dates


from 1000-01-01 00:00:00 from 1970-01-01 00:00:01 UTC
to 9999-12-31 23:59:59 to 2038-01-19 03:14:07 UTC

Storage size: The TIMESTAMP Format: MySQL displays


data type is half the size of the DATETIME values in the format
DATETIME data type, at 4 'YYYY-MM-DD hh:mm:ss'
bytes compared to 8 bytes.
TIME, YEAR DATA TYPES IN MY SQL

TIME Data Type YEAR Data type

When to Use When to use:


• Storing Time of Day: use time when you need • Storing year information: use year when you
to store a specific time of day without any date need to store a year value. This is useful for
information. Examples include scheduling events, historical data, birth years, event years, or any
recording time durations, or managing daily tasks. scenario where only the year is relevant.

• Time Calculations: Ideal for operations involving • Date Comparisons: Suitable for filtering or
time calculations or comparisons, such as finding comparing records based on the year.
events that occur after a certain time.
How to Use: How to Use:
 Definition: The time data types stores the time  Definition: the Year data type stores year
values in the format HH:MM:SS values in either a 2-digit or 4-digit format.
 Range: '-838:59:59’ to '838:59:59'  Range: 1901 to 2155 (for 4-digit format) or 70
to 69 (for 2-digit format).
STRING DATA TYPES: CHAR, VARCHAR
STRING : STORE SEQUENCES OF CHARACTERS.

Char It allocates a predefined number of characters, regardless of the actual


length of the string.

For example :- CHAR(10)Stores a string with a maximum length of 10


characters. If the string is shorter than 10 characters, it will be padded with
spaces to the right.

Varchar It allocates storage space based on the actual length of


the string, saving storage space for shorter strings.

For example :- VARCHAR(255)Stores a string with a maximum


length of 255 characters. Only uses the necessary amount of
storage space for the actual string length.
Feature Char Varchar
DIFFERENCES
BETWEEN CHAR
Storage Fixed -length Variable-length
AND VARCHAR
Padding Yes No

Space Fixed, regardless Variable, only


Usage of data length uses space
needed

Efficiency Less efficient for More efficient for


varying lengths varying lengths
WHEN TO USE CHAR & VARCHAR

Use char when:

•You need fixed-length strings.


•The data has a consistent length, like storing zip codes or phone numbers

Use varchar when:


• You need variable-length strings.
• The data has varying lengths, like storing names, addresses, or
descriptions.
TEXT DATA TYPES IN MYSQL
• MYSQL has four text data types:
TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT:
1. TINYTEXT : The smallest of the text data types, TINYTEXT can store
up to 255 bytes and is used for short information strings.
2. TEXT : This data type can store any kind of text data, including single-byte
and multibyte characters, and can range in size from 1 byte to 4 GB. TEXT
values are stored on disk instead of in the server’s memory.
3. MEDIUMTEXT : LONG and LONG VARCHAR map to MEDIUMTEXT as a
compatibility feature.
4. LONGTEXT : Used to store large blocks of text.
STORAGE SIZES FOR MYSQL TEXT DATA TYPES

TINYTEXT: 255 characters - 255 B and

requires a 1 byte overhead .


TEXT: 65,535 characters - 64 KB and
requires a 2 bytes overhead .

MEDIUMTEXT: 16,777,215 - 16 MB and


requires a 3 bytes of overhead .

LONGTEXT: 4,294,967,295 characters - 4 GB


and requires a 4 bytes of overhead.
• A binary string is a string of bytes.
BINARY Every binary string has a character set
and collation named binary . A
STRING DATA nonbinary string is a string of
TYPES IN characters. It has a character set other
MYSQL than binary and a collation that is
compatible with the character set.
BINARY , VARBINARY

In MySQL that can store string-ish values, such as the BINARY and VARBINARY
columns. These store bytes of data rather than characters, allowing users to store raw
binary data, little bits of binary data that cannot be represented as strings, or do not need
to be stored in that way.

The BINARY column is a fixed length column, while the VARBINARY column is a variable
length column. With VARBINARY columns, you can store up to a set number of bytes, rather
than fixed data types. Although not too commonly used, BINARY and VARBINARY columns
provide an efficient way to store binary data .
BLOB DATA TYPES
•BLOB, OR BINARY LARGE OBJECT, IS A MYSQL DATA TYPE
THAT STORES BINARY DATA LIKE IMAGES, MULTIMEDIA, AND PDF
FILES. BLOB VALUES ARE TREATED AS BINARY STRINGS AND CAN BE
STORED IN RANDOM-ACCESS CHUNKS CALLED SBSPACES.

•TINYBLOB:
•BLOB:
•MEDIUMBLOB:
•LONGBLOB:

•BLOB, OR BINARY LARGE OBJECT, IS A DATA TYPE IN MYSQL THAT


CAN STORE BINARY DATA, SUCH AS IMAGES, VIDEOS, AND AUDIO
FILES:


•EXAMPLES OF FILES STORED IN BLOB
•IMAGES (JPG, JPEG, PNG, GIF, HEIC, WEBP), VIDEOS (MP4, AVI, MOV,
MKV), AUDIO FILES (MP3, WAV, AAC), DOCUMENTS (PDF, TXT, CSV,
DOCX, XLSX), ARCHIVES (ZIP, RAR), EXECUTABLE FILES (EXE, MSI),
BACKUPS (SQL, BAK)
ENUM AND SET DATA TYPES
• ENUM and SET are string data types in MySQL that are used to define columns
that can only contain a set of values. Both types are defined using string values, but
MySQL stores them internally as integers.

• Here are some things to know about ENUM and SET data types in MySQL:
• Data validation
• ENUM and SET columns help ensure that only valid data is entered into a column.
• Readability
• ENUM and SET columns allow you to store readable values in your database.
• Compact data type
• ENUM and SET columns take up less storage space than other data types, such as
strings.

• When to use
• ENUM is useful when you have a fixed set of items that can be stored in the
column, such as days of the week or status flags.

• How to use
• When you insert data into an ENUM column, you can use the index number or the
corresponding string value to represent the value you want to store.
DATA TYPES IN MYSQL

•SQL data types define the type of value that can be stored in a table
column. For example, if you want a column to store only integer values,
you can define its data type as INT.

SQL data types can be broadly divided into the following categories.
1.Numeric data types such as: INT, TINYINT, BIGINT, FLOAT, REAL,
etc.
2.Date and Time data types such as: DATE, TIME, DATETIME, etc.
3.Character and String data types such as: CHAR, VARCHAR, TEXT, etc.
4.Unicode character string data types such as: NCHAR, NVARCHAR,
NTEXT, etc.
5.Binary data types such as: BINARY, VARBINARY, etc.
6.Miscellaneous data types - CLOB, BLOB, XML, CURSOR, TABLE, etc.

You might also like