kingjaga28_177573 avatar image
kingjaga28_177573 asked Erick Ramirez edited

How do I model data for 3 different queries?

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 modeling
10 |1000

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:

10 |1000

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