Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

kingjaga28_177573 avatar image
kingjaga28_177573 asked ·

Doubt in cassandra data modelling

I want to do a data model for tenant-based device table with fields of tenant_id(uuid), id(uuid), name and active_status(boolean). queries that I will fire are fetch all devices by tenant, fetch all device by tenant and active_status, fetch all device bu tenant_id and name and active_status.. my question is do I need to maintain a separate table for tenants_devices, tenant_devices_by_name and tenant_device_by_active_status? 3 separate tables for three scenarios?

data modelling
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Lewisr650 avatar image
Lewisr650 answered ·

Data modeling is key to success with performance in DSE and Cassandra. Definition of the Primary Key not only defines the access pattern efficiencies, but it also defines the physical layout of data on disk which mitigates how much IO is required to retrieve a large amount of data. If you want to retrieve data in different access patterns only using Cassandra, then the typical approach is to make copies of the table with different Primary Key definitions. The implication of this is that adding a single table doubles your data density, compaction implication, repair implications as well as complicating your Data Access Object (DAO). DataStax provides value in these use cases with it's integrated Search capabilities allowing you to store the data in a single table, then generate a Search Core allowing you to support adhoc queries against that single table while reducing data density, compaction and repair implications while enhancing the technology capabilities of a very elegant architecture.

If you are interested in learning more about this topic you might find it valuable to go through the documentation Tutorial found here: https://docs.datastax.com/en/dse/5.1/dse-dev/datastax_enterprise/search/tutorialsDemosTOC.html


Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.