CockroachDB, traditionally known as a distributed, transactionally consistent key-value store, has transitioned to using SQL as the core of its structured data layer. This shift allows CockroachDB to support tables and indexes, facilitating efficient data manipulation and retrieval through SQL queries. The underlying key-value store still plays a critical role, with SQL data encoded into key-value pairs for storage. Each table assigns a unique 64-bit integer ID as a prefix for all keys, and primary keys determine row ordering, enabling optimized data retrieval using index scans. Secondary indexes can be created to improve query efficiency, with unique and non-unique indexes handled differently to maintain data integrity. Null values are not stored as key-value pairs, but indicated by the absence of a key, with a sentinel key ensuring rows with only null values are represented. This approach, similar to systems like MySQL on InnoDB, emphasizes CockroachDB's adaptability in providing SQL functionalities atop a key-value store infrastructure.