Import Data

It’s hard to see what a database is capable of without a real world dataset. Fortunately CrateDB ships with an easy method of obtaining data to experiment with.

Import Sample Data

Open http://SERVER_IP:4200/admin to access the CrateDB Admin UI. Click Get Started to import some sample Twitter data and use the Console tab to try out some queries.

CrateDB Uses Standard SQL

CrateDB uses familiar SQL syntax for performing real-time distributed queries across a cluster. You gain the benefits of a NoSQL based, scalable data store without needing to rewrite your application queries.

For example, we want to see tweets from verified users, returning all column values.

SELECT *
FROM tweets
WHERE user['verified'] = true;

user['verified'] indicates a column that is part of an object data type, in this case, user. This object contains other fields of any type, including other objects.

Analyze Data in Real Time

CrateDB’s SQL support includes distributed aggregation, scalar functions and geospatial support for more complex queries and data analysis.

For example:

SELECT count(*) AS quantity,
  user['verified']
FROM tweets
GROUP BY user['verified']
ORDER BY quantity DESC;

This query counts the number of verified and non-verified twitter users and displays the quantity by each type. count(*) is an aggregation function that returns a count of all the rows that match the query. The GROUP BY clause groups each count result into the two possible values of user['verified'] (true and false).

Next Steps