A columnar database stores the data of an entire column in consecutive memory blocks, while a relational database stores the data of an entire row of a table in consecutive memory blocks.
When a query is run against a column on which a secondary index is created, the database will go to the secondary index (where it is stored) and look for the address of the corresponding row in the table.