Thanks Carlos...This certainly helps..
Sent from Yahoo Mail on Android 
 
  On Fri, Feb 12, 2016 at 2:02 AM, Carlos Alonso<i...@mrcalonso.com> wrote:   
Hi Hari.
I'd suggest having a customers table like this:
CREATE TABLE customers (  customerid UUID,  name VARCHAR,  email VARCHAR,  
phonenr VARCHAR,  PRIMARY KEY(name, email, phonenr)).
This way your inserts could be INSERT INTO customers (customerid, ...) VALUES 
(...) IF NOT EXISTS;Afterwards, you can use your customerid in the dependent 
tables such as:
CREATE TABLE customeraction (  customerid UUID,  action VARCHAR,  time 
TIMESTAMP,  PRIMARY KEY(customerid, action, time)  // Keys definition will, of 
course, depend on the access pattern.)
Before wrapping up I'd like to suggest denormalising a little bit using statics 
if possible.
In case you need to JOIN your customers with any of your dependent tables, that 
will have to be done in application logic as Cassandra doesn't support such 
feature. Instead you can denormalise using statics which will actually almost 
not duplicate any data as the static is saved only once per partition.
An example:
CREATE TABLE customeraction (  customerid UUID,  name VARCHAR STATIC,  email 
VARCHAR STATIC,  phonenr VARCHAR STATIC,  action VARCHAR,  time TIMESTAMP,  
PRIMARY KEY(customerid, action, time)).
This way, you avoid client side joins.
Hope this helps!
Carlos Alonso | Software Engineer | @calonso

On 12 February 2016 at 09:25, Harikrishnan A <hari...@yahoo.com> wrote:

Hello,I have a scenario where I need to create a customer master table in 
cassandra which has attributes like customerid, name, email, phonenr .etc 
..What is the best way to model such table in cassandra keeping in mind that I 
will be using customer id to populate customer information from other 
application work flows.  While inserting , I need to make sure the customer 
profile doesn't exists in this table by verifying the combination for name + 
email + phonenr.  Unfortunately I can't  store the name, email, phonenr in some 
of the tables where I have association with customer data, instead those table 
stores only customer id.   
Thanks & Regards,Hari

  

Reply via email to