PM & AI Chronicles

From Product Thinking to Prompt Engineering – One Tool at a Time

Database Data Types 🔤: The Building Blocks of Data in SQL & NoSQL 🧱🧊

This article is part of the Database Fundamentals Series — where we break down what databases are, how they store information, and how data is organized, accessed, and used behind the scenes. 👉 — Database Fundamentals: Foundation of Data Storage

Every piece of information stored in a database — whether it’s a person’s name, an order amount, a date of birth, or even a full JSON document — has a type.
This “type” tells the database what kind of data it is, how much space it needs, and what operations you can perform on it. Think of data types as the labels on containers in a kitchen:

  • Flour goes in a jar.
  • Milk goes in a bottle.
  • Vegetables go in the fridge.

If you mix them up or put something in the wrong container, things stop working. Databases work the same way.

Yes — but also no. Both relational (SQL) and non-relational (NoSQL) databases use data types, but they don’t follow the same rules.

Relational databases (SQL) are strict.

  • Every column must have a defined data type.
  • The structure is fixed.
  • Types are enforced strongly.

NoSQL databases are flexible.

  • They don’t always require a predefined type.
  • A field in one document can hold a number, while the same field in another document might hold text.
  • Some NoSQL systems infer types automatically.
  • This difference comes from their design philosophies:
  • SQL databases want consistency, structure, and accuracy.
  • NoSQL databases want flexibility, agility, and scale.

Even though SQL and NoSQL store data differently, some basic types — like numbers, text, dates, and Boolean values — are used everywhere. How these types are named or enforced may vary, but the concept is the same.

Don’t worry — this is the “no heavy tech jargon, no headache” version of data types. If you can tell the difference between a number and your name, you’re already qualified to read this article. 😄

Databases support many data types, but almost all of them fall into a few simple categories. Below is a beginner-friendly explanation of each category, how they’re used, and whether they appear in SQL, NoSQL, or both.

Used when you want to store numbers — either whole numbers or numbers with decimals.

✔️ Used In: SQL & NoSQL

  • INT, SMALLINT, BIGINT
  • Store counts or identifiers.
  • Example: number of items ordered → 3
  • DECIMAL(p,s)
  • Great for prices or financial data where accuracy matters.
  • Example: product price → 19.99
  • FLOAT, REAL
  • Used for scientific calculations or values that don’t need perfect precision.
  • Example: temperature reading → 98.6

📝 In NoSQL: you just store them as “number,” but internally it still handles integers vs decimals.

Used for text — names, product descriptions, emails, anything made of letters or symbols.

✔️ Used In: SQL & NoSQL

  • CHAR(n)
  • Used when the text is always the same length.
  • Example: country code → “USA”
  • VARCHAR(n)
  • Most common for text that varies in size.
  • Example: person’s name → “William John”
  • TEXT, NTEXT
  • Good for long notes, descriptions, or documents.
  • Example: blog content → “This article explains…”

📝 In NoSQL: stored as strings or large text values in JSON documents.

Used to store when something happened — dates, times, or both.

✔️ Used In: SQL & NoSQL

  • DATE → 2025-07-25
  • Used for birthdays or event dates.
  • TIME → 13:45:00
  • Used for capturing reservation times or logs.
  • DATETIME, DATETIME2 → 2025-07-25 13:45:00
  • TIMESTAMP
  • Mostly used to track when a record was created or modified.
  • DATETIMEOFFSET
  • Stores date/time along with the timezone.

📝 In NoSQL: stored as strings or numbers, depending on the database (for example, MongoDB has a native Date type).

Used for simple true/false logic.

✔️ Used In: SQL & NoSQL

  • BOOLEAN or BIT
  • Example:
    • isActive = TRUE
    • emailVerified = FALSE

This is one of the simplest and most universal data types.

Used for storing non-text data such as images, audio, PDFs, or encrypted values.

✔️ Used In: SQL & NoSQL

  • BINARY, VARBINARY
  • Used for things like encrypted passwords.
  • BLOB
  • Example: a profile picture stored inside a record.

📝 In NoSQL: Often stored as Base64 strings or binary buffers.

These types are not needed everywhere, but are extremely useful in certain applications.

✔️ Used In:

  • SQL → most of these
  • NoSQL → JSON is native; others vary depending on the database
  • Stores structured data inside one field.
  • Extremely popular in NoSQL and supported in most modern SQL engines.

Example:

{"name": "Alex", "age": 30}
  • Older format used for nested, structured data.
  • Still supported in enterprise SQL systems.
  • UNIQUEIDENTIFIER
  • Used to generate globally unique IDs across systems.
  • Example: 550e8400-e29b-41d4-a716-446655440000
  • GEOMETRY, GEOGRAPHY
  • Used by mapping, GPS, and location-based apps.
  • Example: storing coordinates for a store location.

📝 In NoSQL:

  • JSON is the most widely used.
  • Spatial/geolocation types vary by platform (e.g., MongoDB has native GeoJSON support).
Data Type CategorySQL (Relational)NoSQL (Non-Relational)Beginner Explanation
NumbersINT, BIGINT, DECIMAL, FLOATJust “Number” (flexible)SQL is strict, NoSQL is chill.
TextCHAR, VARCHAR, TEXTString, long textUsed for names, messages, descriptions.
Date & TimeDATE, TIME, DATETIME, TIMESTAMPStored as date objects or stringsSQL has many flavors, NoSQL keeps it simple.
BooleanTRUE/FALSE or BITTRUE/FALSESame idea everywhere.
Binary (Files)BINARY, VARBINARY, BLOBBinary or Base64Used for images, audio, documents.
JSON / XMLJSON, XML (supported in modern SQL)Native JSON (common)For storing nested, structured data.
Spatial (Maps/GPS)GEOGRAPHY, GEOMETRYGeoJSON (varies by system)Used for coordinates and map data.
GUID / Unique IDUNIQUEIDENTIFIERObjectId or random IDsFor generating globally unique IDs.

Data types may sound technical at first, but now you’ve seen that they’re really just different containers for different kinds of information. Whether you’re using a strict SQL database or a flexible NoSQL one, the idea stays the same:

  • Numbers stay numbers
  • Text stays text
  • Dates track time
  • Booleans answer yes/no
  • And special types help you store unique things like JSON, maps, or even images

Think of data types as the database’s way of keeping your information organized, predictable, and usable — without making you solve a math puzzle every time you add a new record. As you keep exploring databases, you’ll notice that these building blocks will appear everywhere.

And now, you know exactly what they mean and when to use them. 👋 On that note, you’re now officially “data-type literate.”