👉Practice: Choose Right SQL Data Types

đŸ§Ē Practice: Define Appropriate SQL Data Types

Practice selecting the most suitable SQL data types for each column based on its purpose. Think about performance, storage, and real-world usage in a Bangladeshi context.

📋 Example 1: Employee Table

Column Description Best Data Type Why?
emp_id Employee ID (unique) NUMBER Used for indexing, numeric comparison is fast
name Employee’s full name (Bangla) NVARCHAR2(100) Supports Bangla characters efficiently
gender 'M' or 'F' CHAR(1) Fixed length for single-character flag
salary Monthly salary in BDT NUMBER(8,2) Handles decimal values with precision
hire_date Date of joining DATE Standard date format
created_at Exact entry timestamp TIMESTAMP Includes time & fractions of a second

đŸ“Ļ Example 2: Delivery System

Column Description Best Data Type Why?
package_id Unique tracking ID VARCHAR2(20) May include letters (e.g., BD12345)
destination Address (Bangla) NVARCHAR2(200) Supports Unicode for addresses in Bangla
delivery_time Duration taken to deliver INTERVAL DAY TO SECOND Measures time between dispatch and delivery
status Delivered, Pending, Failed VARCHAR2(20) Variable-length status strings

📝 Your Turn (Practice)

Choose the best data type for each column:

  1. student_name: Bangla names with variable length
  2. student_id: Numeric ID
  3. birth_date: Date of birth
  4. blood_group: 'A+', 'O-', etc.
  5. total_fee: Payable amount (BDT)
  6. payment_status: Paid / Unpaid / Partial

👉 Try to answer on your own, then scroll to see suggestions:

✅ Suggested Types:

  • student_nameNVARCHAR2(100)

āĻ•োāύ āĻŽāύ্āϤāĻŦ্āϝ āύেāχ:

āĻāĻ•āϟি āĻŽāύ্āϤāĻŦ্āϝ āĻĒোāϏ্āϟ āĻ•āϰুāύ