1. Data Representation


INTEGER/ BIGINT / SMALLINT / TINYINT

→ C/C++ Representation

FLOAT / REAL vs. NUMERIC / DECIMAL

→ IEEE-754 Standard / Fixed-point Decimals

VARCHAR / VARBINARY / TEXT / BLOB

→ Header with length, followed by data bytes.

TIME / DATE / TIMESTAMP

→ 32/64-bit integer of (micro)seconds since Unix epoch

1.1 Variable Precision Numbers

FLOAT / REAL

Inexact, variable-precision numeric type that uses the "native" C/C++ types.

1.2 Fixed Precision Numbers

NUMERIC / DECIMAL

Numeric data types with (potentially) arbitrary

precision and scale. Used when rounding errors are unacceptable.

typedef unsigned char NumericDigit; 
typedef struct { 
	int ndigits; 
	int weight; 
	int scale; 
	int sign; 
	NumericDigit *digits;
 } numeric;
typedef int32 decimal_digit_t; 
struct decimal_t {
	int intg; /* # of Digits Before Point */
	int frac; /* # of Digits After Point */
	int len;  /* Length (Bytes) */
	bool sign;
	decimal_digit_t *buf;
};

1.3 Large Values

Most DBMSs don't allow a tuple to exceed the size of a single page.