How can i retrieve data from two tables in Cassandra Database - nosql

I have to retrive the data from two tables,
Here are my two tables in Cassandra DataBase.
employee is keyspace,
Two tables:
emp:- "eno" is primay key,"username","password"
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?

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.

Related

PostgresSQL ranking across two tables with same columns

I have two tables, studentrecordupdated and studentrecordlegacy, with student record legacy being in the legacy schema.
Both the forms have the same data, only difference being that the studentrecordlegacy table has record forms which are not in the studentrecordupdated table. I am joining these two tables on studentid.
How do I don't a rank over partition by using both tables (some of the records in the legacy table are more recent than in the updated table)?

Yii2 multidatabase query

I'm struggling with creating activequery joining data from 2 different databases.
Both Databases are on same machine, on PostgreSQL.
In one DB i have almost all my data, but two columns - 'name' and 'region_id', which are in second DB.
I've made relation and i can get these values, but the problem is i need to get values from DB1 depending on region_id from DB2.
DB1(table districts):
district_id -> relation called 'topology' with DB2(id),
some more data...
DB2(table district):
id,
name,
region_id.
I got Two models, to both tables and they works well.
In model for DB1 i got relation to table in DB2 called 'topology', and if i try:Districts::find()->joinWith('topology')->all(); all i get is DB Exception with message Relation not exists.
All in need to do is add clause where to get records with only one region_id...
Any suggestions?
Thanks in advance.
i think multi database work only for MySQL
for other DB multi database join doesn't work
but in Yii2 multidatabase work when you use relation If you models using a different databases

Talend, Postgres and sequences

I have a JPA application and associated Postgres schema that was designed with a single sequence table (not a sequence). I am trying to populate several tables using Talend tPostgresqlOutput. These tables have keys that are sequenced by the JPA application. I am at a loss to work out how to read a sequence number from the table, update it and then use the sequence number to key a record on an insert with Talend. I can work it through with a sequence, but this is a table.

What should be the strategy to read from many tables having millions rows each in postgresql?

I have following scenario while using postgresql -
No of tables - 100 ,
No of rows per table - ~ 10 Million .
All the tables have same schema E.g. each table contains daily call records of a company. So 100 tables contain call records of 100 days.
I want to make following type of queries on these tables -
For each column of each table get count of records having null value in that column.
So considering above scenario, what can be the major optimizations in table structures ? How should i prepare my query and does there exist any efficient way of querying for such cases
If you're using Postgres table inheritance, a simple select count(*) from calls where foo is null will work fine. It will use an index on foo provided null foo rows aren't too common.
Internally, that will do what you'd do manually without table inheritance, i.e. union all the result for each individual child table.
If you need to run this repeatedly, maintain the count in memcached or in another table.

DB2 replication of records across differing schemas

We have 2 db2 instances, each with a DB having tables with differing sets of columns. For e.g. Table T1 has 5 columns in one DB while having 3 columns in the other DB.
We would like to replicate data from T1 from one DB to another. Whil replicating, we would additionally want to apply certain transformation so that the 5 columns in the source table can be mapped to 3 columns in the target.
SQL Server lets you modify the stored procs that insert the record in the target DB. Its called MCALL or XCALL mechanism.
Does DB2 have such a feature by which a source table having one schema can be replicated to a target table with a different schema?
Thanks,
Yash
There are various replication mechanisms that you can use with DB2, all of them allow you to manipulate replicated data. You didn't mention what type of replication you are planning to use; here's an example for SQL Replication: http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.swg.im.iis.db.repl.sqlrepl.doc/topics/iiyrssubmanipoverview.html