Tables and Data Types

Learn how tables store records and how data types define column values.

Tables and Data Types in RDBMS

When working with a Relational Database Management System, two of the most important concepts to understand are tables and data types. Every piece of information stored in a database lives inside a table, and every value in that table has a specific data type.

Think of a database as a digital filing cabinet. Inside the cabinet are many folders, and each folder contains information about one subject. In an RDBMS, these folders are called tables.

Choosing the correct data type for each piece of information helps keep the database organized, accurate, and efficient.

What is a Table?

A table is a collection of related data arranged in rows and columns. Each table stores information about one type of object, such as students, employees, customers, or products.

For example, a school database might have a Students table that stores student information.

Student IDNameAgeCity
101Rahul18Delhi
102Priya19Mumbai
103Aman20Jaipur
  • The table is named Students.
  • Each row represents one student.
  • Each column represents one type of information.

This organized structure makes it easy to store, search, update, and manage records.

Understanding Rows and Columns

Rows

A row represents one complete record. In a Students table, one row contains all the information about one student.

Student IDNameAge
101Rahul18

Columns

A column represents one category of information. Examples include Student ID, Name, Age, and City.

Every value in a column should be of the same type. For example, the Age column should contain numbers, not names or dates.

Why Do We Use Tables?

Tables provide a simple and organized way to manage information. Instead of storing everything in one large file, databases divide information into multiple tables based on purpose.

  • Easy to understand
  • Quick to search
  • Simple to update
  • Reduces confusion
  • Supports relationships between different tables

A school database may have separate Students, Teachers, Courses, and Fees tables. Each table focuses on one type of information, making the database cleaner and easier to maintain.

What are Data Types?

A data type defines the kind of information that can be stored in a column.

Just as a form asks you to enter the correct kind of information, such as your name, age, or date of birth, a database uses data types to ensure that only valid values are stored.

  • A person's name should contain text.
  • Age should contain numbers.
  • Date of birth should contain a date.

Using the correct data type helps prevent mistakes and improves database performance.

Common Data Types in RDBMS

Integer (INT)

The INT data type stores whole numbers. It is commonly used for student IDs, quantity, age, and product stock.

Decimal (DECIMAL)

The DECIMAL data type stores numbers with decimal points, such as 99.95 or 1250.75. It is useful for product prices, salaries, and account balances.

Character (CHAR)

The CHAR data type stores fixed-length text. It is useful when the data always has the same length, such as country codes or gender codes.

text
A
YES
IND

Variable Character (VARCHAR)

The VARCHAR data type stores text of different lengths, such as names, email addresses, cities, and product names. Because it stores only the required number of characters, it helps save storage space.

Date

The DATE data type stores calendar dates, such as 2026-07-08 or 2025-12-31. It is used for date of birth, joining date, and order date.

Boolean

Some RDBMS systems support the BOOLEAN data type. It stores only two values: TRUE or FALSE. It is useful for fields such as Is Active, Is Paid, or Is Verified.

Creating a Table

The following SQL statement creates a simple Students table.

sql
CREATE TABLE Students (
    StudentID INT,
    Name VARCHAR(100),
    Age INT,
    City VARCHAR(50),
    AdmissionDate DATE
);
  • StudentID stores numbers.
  • Name stores text.
  • Age stores whole numbers.
  • City stores text.
  • AdmissionDate stores dates.

Each column has an appropriate data type based on the information it will hold.

Inserting Data into a Table

After creating the table, we can add records.

sql
INSERT INTO Students
(StudentID, Name, Age, City, AdmissionDate)
VALUES
(101, 'Rahul', 18, 'Delhi', '2026-07-08');

The database checks that every value matches the correct data type before storing it. This helps maintain accurate and reliable data.

Choosing the Right Data Type

Selecting the correct data type is an important part of database design.

  • Store phone numbers as VARCHAR, not INT, because they may contain leading zeros or special characters.
  • Store prices as DECIMAL instead of INT to preserve decimal values.
  • Store dates using the DATE type rather than plain text so the database can sort and compare them correctly.

Using suitable data types makes your database more efficient, easier to query, and less likely to contain invalid data.

Key Takeaways

  • A table stores related information in rows and columns.
  • Each row represents one complete record.
  • Each column stores one type of information.
  • Data types define what kind of values can be stored in each column.
  • Common data types include INT, DECIMAL, CHAR, VARCHAR, DATE, and BOOLEAN.
  • Choosing the correct data type improves accuracy, performance, and storage efficiency.
  • SQL uses the CREATE TABLE statement to define tables and their data types.
  • A well-designed table is the foundation of a reliable and efficient relational database.
Let's learn with DevBrainBox AI