A data type is a property that instructs a computer system how to interpret the value of a piece of data.
Understanding data types ensures that data is in the desired format. Also each property’s value is as expected.
To effectively describe event and entity properties, you’ll need a thorough understanding of data types.
To assure data accuracy and prevent data loss, a well-defined tracking plan must include the data type of each property.
Let’s have a look at some of the most popular data kinds before we get into the relevance of data types.
Common Data Types
It is the most common numeric data type, that stores numbers without a fractional component (-707, 0, 707).
Floating Point (float)
It’s also a numeric data type for storing numbers with fractional components, such as monetary values (707.07, 0.7, 707.00).
Please keep in mind that number is a data type that encompasses both int and float types.
It stores a single letter, digit, punctuation mark, symbol, or blank space.
String (str or text)
It’s a string of characters that’s the most common data type for storing text.
A string can also contain digits and symbols, but it will always be regarded as text.
A phone number can be as a string (+1-999-666-3333) or as an integer (9996663333).
It represents the true and false values. When working with the boolean data type, keep in mind that a boolean value can alternatively be represented as 0 (false) or 1 (true) (for true).
Enumerated type (enum)
It has a minimal number of predefined unique values (sometimes called elements or enumerators) that we can compare and add to an enumerated data type variable.
An enumerated type’s values can be textual or numerical. The boolean data type is, in fact, a pre-defined enumeration of the true and false values.
An array, often known as a list, is a data type that contains a sequence of elements, usually all of the same type, in a predefined order.
The structure of data held by an array is referred to as an array data structure since an array stores numerous items or values.
An integer index (0, 1, 2,…) can be useful to access each element of an array, and the total number of items in an array represents the array’s length.
An array variable genre, for example, can store one or more of the elements rock, jazz, or blues. The three values’ indices are 0 (rock), 1 (jazz), and 2 (blues), and the array’s length is 3. (since it contains three elements).
Continuing with the music app as an example, if you are prompted to select one or more of the three genres and you happen to enjoy all three (kudos), the variable genre will store all three aspects (rock, jazz, blues).
Needs no explanation; typically stores a date in the YYYY-MM-DD format (ISO 8601 syntax).
The time is stored in the hh:mm:ss format. It can be used to store the time elapsed or the time interval between two occurrences, which could be more than 24 hours, in addition to the time of day.
For example, the period since an event occurred could be 72 hours or more (72:00:59).
Stores a value containing both date and time together in the YYYY-MM-DD hh:mm:ss format.
A timestamp is an integer that represents the number of seconds that have passed since midnight (00:00:00 UTC) on January 1, 1970.
Computer systems often utilize it to log the exact date and time of an occurrence, down to the second, in a format that is unaffected by time zones. As a result, unlike datetime, the timestamp remains constant regardless of your location.