3
votes

I have to retrive the data from two tables,

Here are my two tables in Cassandra DataBase.

employee is keyspace,

Two tables:

  1. emp:- "eno" is primay key,"username","password"
  2. Dept:-"dno" is primary key ,"eno","dname"

Now i want to retrieve the data from two tables, e.g. eno,username,password,dno,dname.

How can i retrieve data from two tables?

1

1 Answers

1
votes

How can i retrieve data from two tables?

You can't do it in one query if that is what you are asking. That means that you have to carry out two queries and let your application simulate a join, or the other option, denormalize your data so it is in one table.

As for actually carrying out the query there are bundles of APIs that can retrieve data from Cassandra.

Assuming your column families are emp and Dept you can do querying using the cli:

$ ./cassandra-cli -host localhost -port 9160
$ [default@unknown] USE employee
# single row (collection of columns)
$ [default@employee] GET emp['eno']['username']['password'] as ascii;
# 10 rows for emp column family (aka table)
$ [default@employee] LIST  emp limit 10;

Check the documentation for Cassandra 0.7 for using the CLI.