0
0
Hadoopdata~10 mins

CRUD operations in HBase in Hadoop - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - CRUD operations in HBase
Start
Create Table
Insert Data (Put)
Read Data (Get/Scan)
Update Data (Put)
Delete Data (Delete)
End
This flow shows the main steps of CRUD in HBase: create a table, insert data, read data, update data, and delete data.
Execution Sample
Hadoop
create 'users', 'info'
put 'users', 'row1', 'info:name', 'Alice'
get 'users', 'row1'
put 'users', 'row1', 'info:name', 'Alicia'
get 'users', 'row1'
delete 'users', 'row1', 'info:name'
get 'users', 'row1'
This code creates a table, inserts a row, reads it, updates the row, reads again, and then deletes the cell followed by a final read.
Execution Table
StepCommandActionResult
1create 'users', 'info'Create table 'users' with column family 'info'Table 'users' created
2put 'users', 'row1', 'info:name', 'Alice'Insert 'Alice' into 'row1' under 'info:name'Data inserted
3get 'users', 'row1'Read data from 'row1'{'info:name' => 'Alice'}
4put 'users', 'row1', 'info:name', 'Alicia'Update 'info:name' in 'row1' to 'Alicia'Data updated
5get 'users', 'row1'Read updated data from 'row1'{'info:name' => 'Alicia'}
6delete 'users', 'row1', 'info:name'Delete 'info:name' from 'row1'Data deleted
7get 'users', 'row1'Read data from 'row1' after deletion{}
💡 All CRUD operations completed; final get shows empty result after deletion.
Variable Tracker
VariableStartAfter Step 2After Step 4After Step 6Final
Table 'users'Not createdCreatedCreatedCreatedCreated
Row 'row1' dataEmpty{'info:name': 'Alice'}{'info:name': 'Alicia'}{}{}
Key Moments - 2 Insights
Why does the 'get' command after deletion return an empty result?
Because the 'delete' command removed the 'info:name' cell from 'row1', so no data remains to retrieve, as shown in execution_table step 7.
Is 'put' used for both inserting and updating data?
Yes, 'put' inserts data if the cell is empty or updates it if the cell already exists, as seen in steps 2 and 4 of the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3, what data is returned by the 'get' command?
A{'info:name' => 'Alice'}
B{}
C{'info:name' => 'Alicia'}
DError: No such row
💡 Hint
Refer to execution_table row 3 under 'Result' column.
At which step does the data in 'row1' change from 'Alice' to 'Alicia'?
AStep 2
BStep 4
CStep 6
DStep 7
💡 Hint
Check execution_table steps 2 and 4 for 'put' commands and their results.
If we skip the delete command at step 6, what would the final 'get' at step 7 return?
A{}
B{'info:name' => 'Alice'}
C{'info:name' => 'Alicia'}
DError: Table not found
💡 Hint
Look at variable_tracker for 'Row row1 data' after step 4 and consider no deletion happened.
Concept Snapshot
CRUD in HBase:
- Create table: create 'table', 'family'
- Insert/Update: put 'table', 'row', 'family:qualifier', 'value'
- Read: get 'table', 'row'
- Delete: delete 'table', 'row', 'family:qualifier'
- 'put' works for insert and update
- 'get' returns current data or empty if none
Full Transcript
This visual execution shows CRUD operations in HBase. First, we create a table named 'users' with a column family 'info'. Then, we insert data into row 'row1' under 'info:name' with value 'Alice'. Next, we read the data from 'row1' and see 'Alice'. We update the same cell to 'Alicia' using another put command. Reading again shows the updated value. Then, we delete the cell 'info:name' from 'row1'. Finally, reading after deletion returns empty data. The variable tracker shows the table creation and how the row data changes after each operation. Key moments clarify that 'put' is used for both insert and update, and that deletion removes data so 'get' returns empty. The quiz tests understanding of data changes and command effects. This step-by-step trace helps beginners see exactly how HBase CRUD commands work.