What is BigTable?
Bigtable is a distributed database that runs on clusters for applications that has massive data. Its mainly designed for unstructured data, and scales horizontally.
Cloud Bigtable is not a relational database system. It stores data in key-value pairs.
When to choose BigTable and BigQuery?
- For Interactive querying in an online analytical processing system use BigQuery.
- BigQuery is a data warehouse application, and it stores data in structured tables.
- BigQuery supports SQL queries whereas BigTable doesn’t support SQL queries.
- BigTable is not a recommended solution for a small volume of data(< 1 TB).
- BigTable is characteristic of a NoSQL system whereas BigQuery is somewhat of a hybrid where it is mainly used for SQL queries but it does support NoSQL as well.
- For e.g. If you want to do analytics or business intelligence from collected data from different sources into one location i.e BigQuery.
- Simple, Database — BigTable whereas Analytics — BigQuery
- This lab walks you through BigTable, how it is different from BigQuery.
- You will be creating a BigTable Cluster and Table.
- Login into GCP Console.
- Creating BigTable Instance.
- Creating a BigTable Cluster.
- Create a Table.
- Create a Column Family.
- Inserting data into Table.
- Reading data through the Table.
Creating a BigTable Instance
- Click on the hamburger icon on the top left corner.
- Click on Bigtable under the Databases section.
3. Click on Create Instance.
4. Enter instance name as whizlabs-bt-admin.
5. It will automatically generate an instance id like whizlabs-bt-admin.
6. Click on Continue.
7. Select the storage type as HDD.
8. Click on Continue.
Creating a BigTable Cluster
- Enter the Cluster ID as whizlabs-cluster.
- Select the region as us-central1 and zone you can choose any.
- Enter the nodes as 1.
4. Click on Create.
5. You can see your Instance listed. Click on your instance id.
6. You will be able to see more details about the cluster.
Creating a Table and querying the data
- Start Cloud Shell from the top bar.
- Enter the command and replace project id with your project id:-
echo -e “project = <project_id>\ninstance = whizlabs-bt-admin” > ~/.cbtrc
It will store the variables for project id and instance id in a file name cbtrc.
3. Enter the command to create a table.
cbt createtable whizlabs-bt-lab
4. Enter the command to create a column family.
cbt createfamily whizlabs-bt-lab employee_name
5. Enter the command to insert the data.
cbt set whizlabs-bt-lab r1 employee_name:c1=martha
6. Enter the command to insert the data.
cbt set whizlabs-bt-lab r1 employee_name:c2=rachel
7. Enter the command to fetch the data.
cbt read whizlabs-bt-lab
Completion and Conclusion:
- In this lab, you have created a BigTable Instance.
- You have created a BigTable Cluster
- You have created a Table and Column Family in Cluster.
- You have inserted data into the table.
- You have read the data from the table.