Currently we have a table which we query using shipment_id and in future we have a need to query based on status field Current Table :
CREATE TABLE shipment (
shipment_id text,
tenant_id text,
actual_arrival_time text,
actual_dep_time text,
email_ids set,
is_deleted boolean,
modified_by text,
modified_time timestamp,
planned_arrival_time text,
planned_dep_time text,
route_id text,
shipment_departure_date text,
status_code text,
PRIMARY KEY (shipment_id, tenant_id)
);
CREATE INDEX shipment_id_index ON shipment (tenant_id);
Current Query's
1) SELECT * FROM shipment where tenant_id=?0 ALLOW FILTERING ;
2) SELECT * FROM shipment WHERE shipment_id=?0 and tenant_id=?1 ;
Pending/Future Query's
list of shipment id's for given status code as of now 3) SELECT * FROM shipment WHERE tenant_id = 'y' and status_code = x ? ;
4) list of shipment id's for given status code for last 1 week
5) list of shipment id's for which got delayed
Above table There could be 10-15 unique tenants and will have 1 shipment_id,1 tenant_id 1 row per table and status_code will be changing over the time as shipment progresses , from Shipment_started, shipment_progress, shipment_delayed, shipment_delayed_completed and shipment_completed etc each shipment in its life time will go through 3-5 statuses , the current table will be updated only when there is a status change for a given shipment_id .
I need to create a new table which can address query's something like below
3) list of shipment's for a given tenant which have status_code = 'x' as of now
4) list of shipment's for a given tenant which have status_code = 'x' for last 1 week
5) list of shipment's for which got delayed ?