Advertisement
Intermediate SQL Server, Data Types & Schema Design

How do you choose an appropriately sized data type for a column to balance storage efficiency with future flexibility?

Short answer

You consider the realistic range of values a column will ever need to hold, choosing a smaller data type like TINYINT or SMALLINT when the range is genuinely limited to save storage space, while avoiding overly restrictive types that might require a costly schema change later if…

Save SQL Server mock interview
Advertisement
AModel answer
You consider the realistic range of values a column will ever need to hold, choosing a smaller data type like TINYINT or SMALLINT when the range is genuinely limited to save storage space, while avoiding overly restrictive types that might require a costly schema change later if the business requirements grow beyond what was originally expected.
-- TINYINT stores 0 to 255, sufficient for something like an age
CREATE TABLE Employees (
  Age TINYINT,
  Salary DECIMAL(12,2)
);
Real-world example
A human resources system uses TINYINT for an employee's age since it will realistically never need to store a value close to that data type's maximum limit, saving a small amount of storage across millions of employee records.
Likely follow-ups
  • What is the storage size difference between TINYINT, SMALLINT, and INT?
  • How do you safely change a column's data type on a table that already contains data?
Related topics