Overview
PruebaETL uses specific SQL Server data types to ensure data integrity, proper storage, and optimal performance. This reference documents all data types used in the database schema.SQL Server Data Types
NVARCHAR
Description: Variable-length Unicode string data type that supports international characters. Usage in PruebaETL:NVARCHAR(255)- Cliente namesNVARCHAR(100)- City namesNVARCHAR(50)- Segments, channels, date strings in raw tablesNVARCHAR(10)- Currency codes
NVARCHAR uses 2 bytes per character. Use it for all text fields that may contain special characters.
DECIMAL
Description: Exact numeric data type with fixed precision and scale. Usage in PruebaETL:DECIMAL(18,2)- Monetary amounts (total sales)
- 18 digits total precision
- 2 digits after decimal point
- Range: -999,999,999,999,999.99 to 999,999,999,999,999.99
DATE
Description: Stores only the date (year, month, day) without time component. Usage in PruebaETL:- Cliente registration dates (
fecha_registro) - Sale transaction dates (
fecha)
YYYY-MM-DD
Storage: 3 bytes
Range: 0001-01-01 to 9999-12-31
DATETIME
Description: Stores both date and time with precision to milliseconds. Usage in PruebaETL:- Audit timestamps (
fecha_creacion,fecha_actualizacion) - Raw data load timestamps (
fecha_carga)
YYYY-MM-DD HH:MM:SS.mmm
Storage: 8 bytes
Range: 1753-01-01 to 9999-12-31
Precision: 3.33 milliseconds
GETDATE() is used as default value to automatically capture creation and update timestamps.
INT
Description: 4-byte integer data type. Usage in PruebaETL:- Primary keys (with IDENTITY for auto-increment)
- Foreign keys
- All ID fields
Data Type Selection Guidelines
Text Data
| Scenario | Data Type | Example |
|---|---|---|
| Names, descriptions | NVARCHAR(255) | Cliente names |
| Short codes | NVARCHAR(10) | Currency codes (USD, DOP) |
| Medium text | NVARCHAR(100) | City names |
| Categories | NVARCHAR(50) | Segments, channels |
Numeric Data
| Scenario | Data Type | Example |
|---|---|---|
| Monetary amounts | DECIMAL(18,2) | Sale totals |
| IDs and counters | INT | Primary/foreign keys |
Date/Time Data
| Scenario | Data Type | Example |
|---|---|---|
| Business dates | DATE | Registration date, sale date |
| Audit timestamps | DATETIME | Created at, updated at |
Special Considerations
NULL vs NOT NULL
NOT NULL fields:- Primary keys
- Foreign keys
- Required business fields (nombre, total)
- Optional dates (fecha_registro)
- Historical audit fields
IDENTITY Property
Used for: Auto-incrementing primary keys in master tables. Syntax:IDENTITY(seed, increment)
DEFAULT Values
Automatic timestamps:Complete Schema Example
Related Resources
Functions Reference
Learn about data normalization functions
Troubleshooting
Common data type issues and solutions