đ§Ē 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:
- student_name: Bangla names with variable length
- student_id: Numeric ID
- birth_date: Date of birth
- blood_group: 'A+', 'O-', etc.
- total_fee: Payable amount (BDT)
- payment_status: Paid / Unpaid / Partial
đ Try to answer on your own, then scroll to see suggestions:
✅ Suggested Types:
student_name
→ NVARCHAR2(100)
āĻোāύ āĻŽāύ্āϤāĻŦ্āϝ āύেāĻ:
āĻāĻāĻি āĻŽāύ্āϤāĻŦ্āϝ āĻĒোāϏ্āĻ āĻāϰুāύ