Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Cassandra a column oriented or columnar database

Columnar database should store group of columns together. But Cassandra stores data row-wise. SS Table will hold multiple rows of data mapped to their corresponding partition key. So I feel like Cassandra is a row wise data store like MySQL but has other benefits like "wide rows" and every columns are not necessarily to be present for all the rows and of course it's in memory . Please correct me if I'm wrong.

like image 216
saktheesh Avatar asked Aug 22 '14 07:08

saktheesh


People also ask

Is Cassandra columnar?

Cassandra, on the other hand, is a columnar NoSQL database, storing data in columns instead of rows. A column in a Cassandra database contains three fields: the name of the column or key, the value against the key, and a time stamp.

Is Cassandra row or column based?

Cassandra is column family but not column-oriented. It stores the row with all its column families together. Hbase is column family as well as stores column families in column-oriented fashion. Different column families are stored separately in a node or they can even reside in different node.

Is Cassandra a columnar database or key-value?

Cassandra is a NoSQL database, which is a key-value store. Some of the features of Cassandra data model are as follows: Data in Cassandra is stored as a set of rows that are organized into tables.

What type of database is Cassandra?

Cassandra is a NoSQL distributed database. By design, NoSQL databases are lightweight, open-source, non-relational, and largely distributed. Counted among their strengths are horizontal scalability, distributed architectures, and a flexible approach to schema definition.


4 Answers

If you go to the Apache Cassandra project on GitHub, and scroll down to the "Executive Summary," you will get your answer:

Cassandra is a partitioned row store. Rows are organized into tables with a required primary key.

Partitioning means that Cassandra can distribute your data across multiple machines in an application-transparent matter. Cassandra will automatically repartition as machines are added and removed from the cluster.

Row store means that like relational databases, Cassandra organizes data by rows and columns.

"So I feel like Cassandra is a row wise data store"

And that would be correct.

like image 171
Aaron Avatar answered Oct 28 '22 13:10

Aaron


  • In a Column oriented or a columnar database data are stored on disk in a column wise manner.

    e.g: Table Bonuses table

       ID         Last    First   Bonus
       1          Doe     John    8000
       2          Smith   Jane    4000
       3          Beck    Sam     1000
    
  • In a row-oriented database management system, the data would be stored like this: 1,Doe,John,8000;2,Smith,Jane,4000;3,Beck,Sam,1000;

  • In a column-oriented database management system, the data would be stored like this:
    1,2,3;Doe,Smith,Beck;John,Jane,Sam;8000,4000,1000;

  • Cassandra is basically a column-family store

  • Cassandra would store the above data as:

    Bonuses: { row1: { "ID":1, "Last":"Doe", "First":"John", "Bonus":8000}, row2: { "ID":2, "Last":"Smith", "Jane":"John", "Bonus":4000} ... }

  • Vertica, VectorWise, MonetDB are some column oriented databases that I've heard of.

  • Read this for more details.

Hope this helps.

like image 44
tharindu_DG Avatar answered Oct 28 '22 11:10

tharindu_DG


A good way of thinking about cassandra is as a map of maps, where the inner maps are sorted by key. A partition has many columns, and they are always stored together. They are sorted by clustering keys - first by the first key, then the next, then next...and so on. Partitions are then replicated amongst replicas. It's not necessarily stored as "rows" as different rows are stored on different nodes based on replication strategy and active hashing algorithm. In other words, a partition for ProductId 1 is likely not stored next to ProductId 2 if ProductId is the partition key. However the coloumns for Product Id 1, are always stored together.

As for definitions, most NoSQL stores are blurring the lines one way or the other. They usually span multiple categories. I'll leave it up to you to decide whether this qualifies as a columnar database or not :)

like image 3
ashic Avatar answered Oct 28 '22 13:10

ashic


It is a wide column database and is also known as column family databases. The definition from Wikipedia also helps further:

Wide-column stores such as Bigtable and Apache Cassandra are not column stores in the original sense of the term, since their two-level structures do not use a columnar data layout. In genuine column stores, a columnar data layout is adopted such that each column is stored separately on disk. Wide-column stores do often support the notion of column families that are stored separately. However, each such column family typically contains multiple columns that are used together, similar to traditional relational database tables. Within a given column family, all data is stored in a row-by-row fashion, such that the columns for a given row are stored together, rather than each column being stored separately. Wide-column stores that support column families are also known as column family databases.

Reference: https://en.wikipedia.org/wiki/Wide-column_store

like image 3
srth12 Avatar answered Oct 28 '22 12:10

srth12