Lesson 8/100

Tutorials MySQL Tutorial

Data Types — Complete Guide

Data Types — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of MySQL Tutorial on Toolliyo Academy.

On this page

MySQL Tutorial · Lesson 8 of 100

Data Types

BasicsAdvanced

Basics · 1 — SQL · ~6 min · MySQL — Foundations

What is this?

Each column has a type: INT for counts, DECIMAL for money, DATE for calendar days, JSON for flexible payloads. Picking the right type saves space and prevents bad data.

Why should you care?

Storing rupee amounts in FLOAT causes rounding errors on GST totals; storing phone numbers in INT drops leading zeros.

See it live — copy this example

Run in MySQL Workbench or the mysql CLI.

CREATE TABLE IF NOT EXISTS products (
  product_id   INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  sku          VARCHAR(40) NOT NULL,
  price_inr    DECIMAL(10,2) NOT NULL,
  attrs        JSON,
  is_active    TINYINT(1) NOT NULL DEFAULT 1
);

What happened?

  • price_inr uses DECIMAL(10,2) for paise-accurate money.
  • attrs is JSON for color/size without ALTER every launch.
  • TINYINT(1) acts as boolean for active flag.

Practice next

  1. Create products table in DataFlow.
  2. Insert: INSERT INTO products (sku, price_inr, attrs) VALUES ('DF-TSHIRT', 799.00, JSON_OBJECT('size','M','color','blue'));
  3. Select attrs: SELECT sku, attrs->>'$.color AS color FROM products;
  4. Change attrs to store an array: JSON_ARRAY('red','blue').
  5. Use CAST(price_inr AS CHAR) in SELECT and compare display.

Remember

Match types to real data shape. DECIMAL for money, JSON for semi-structured fields. Wrong types cause silent bugs or insert failures.

Flipkart-style SKU attrs

New festival badge lives in products.attrs JSON instead of ten nullable columns.

Outcome: Catalog team ships badges without weekly migrations.

Interview prep for this lesson

Practice these questions aloud after reading—each links to a full structured answer.

Junior Detailed
Explain SQL queries in the context of MySQL.
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. Explain a bit more How to structure your answer (60–90 seconds) Define SQL queri…
Mid Detailed
What are common mistakes teams make with Schema design when using MySQL?
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. Explain a bit more How to structure your answer (60–90 seconds) Define Schema de…
Senior Detailed
How would you debug a production issue related to Transactions in a MySQL application?
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. Explain a bit more How to structure your answer (60–90 seconds) Define Transacti…
Junior Detailed
Describe a real-world scenario where Normalization mattered in a MySQL project.
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. Explain a bit more How to structure your answer (60–90 seconds) Define Normaliza…
Questions on this lesson 0

Sign in to ask a question or upvote helpful answers.

No questions yet — be the first to ask!

MySQL Tutorial
Course syllabus

MySQL Tutorial

MySQL — Foundations
MySQL — Queries & Clauses
MySQL — Joins & Relationships
MySQL — Functions & Window Functions
MySQL — Transactions & Concurrency
MySQL — Stored Procedures & Triggers
MySQL — Indexing & Performance
MySQL — Advanced MySQL
MySQL — Security & Cloud MySQL
MySQL — Real-World Projects
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details