EN - FR - DE - ES - IT - PT -

LexiconDream

🔤 Data Type

A classification specifying the kind of value a field can hold.

Data Type

A data type defines what kind of value a field can hold. Integer, decimal, string, date, boolean, binary. The type determines what operations are valid and how much space the value takes. You can add two integers. You cannot add an integer and a date without conversion. You can sort strings alphabetically. You cannot sort them numerically unless they contain numbers. The type is a contract between the data and the system that stores it.

Choosing the wrong type causes problems. Storing a phone number as an integer drops leading zeros. Storing a price as a floating-point number introduces rounding errors that accumulate in financial calculations. Storing a date as a string makes range queries slow and error-prone. Storing a boolean as a string wastes space and invites typos like "ture". Each type has a purpose. Integers for counts. Decimals for money. Strings for text. Dates for temporal values. Booleans for true or false. Binary for files and hashes. Some databases add specialized types: JSON for semi-structured data, arrays for lists, geospatial types for coordinates. The type system enforces consistency. It catches errors at insert time rather than at query time. That early detection is worth the constraints it imposes.

Common data types

Data types are guardrails. They keep bad values out and make good values easier to work with.

Comments

No comments yet. Be the first to share a thought.

Leave a comment