07 - Acquire and Access Data Using NoSQL Database
07 - Acquire and Access Data Using NoSQL Database
NoSQL Database
Course Road Map
Module 4: Data Unification and Analysis Lesson 08: Primary Administrative Tasks
for NoSQL Database
7-2
Objectives
7-3
What is a NoSQL Database?
• Is a key-value database
• Is accessible by using Java APIs
• Stores unstructured or semi-structured data
KVStore
as byte arrays
• NoSQL Database is a nonrelational database
Benefits
• Easy to install and configure
• Highly reliable
• General-purpose database system
• Scalable throughput and predictable latency
• Configurable consistency and durability
7-4
RDBMS Compared to NoSQL
RDBMS NoSQL
7-5
RDBMS Compared to NoSQL
7-6
HDFS Compared to NoSQL
HDFS NoSQL
Batch-oriented Real-time
7-7
Points to Consider Before Choosing NoSQL
7-8
NoSQL Key-Value Data Model
Each record consists of a key-value pair.
{“name" : “User",
name fname lname "namespace" :
"com.company. avro",
"type" : "record“,
"fields":
user/userid subscriptions expiration date [{"name": “userId",
"type": “Integer",
"default": 0}
picture .jpg ]
}
7-9
Acquiring and Accessing Data in a NoSQL DB
Primary Tasks
• Creating Tables
– Create a table (parent or child)
– Add the table to the KVStore
• Adding or Removing Data
– Use the Table API
– Insert Rows
– Delete Rows
• Reading Data
– Retrieve a single record
– Retrieve multiple records
7 - 10
Primary (Parent) Table Data Model
Table Name
Primary Key1 Field 1 Field 2 Field 3
7 - 11
Table Data Model: Child Tables
7 - 12
Creating Tables
7 - 13
Creating Tables: Two Options
1 2
CLI APIs
7 - 14
Accessing the CLI
2
java -jar $KVHOME/lib/kvcli.jar
-port <port number>
-host <host name>
-store kvstore
7 - 15
Executing a DDL Command
7 - 16
Viewing Table Descriptions
Specific Table
execute "describe AS
JSON table <tablename>
[fields]"
7 - 17
Recommendation: Using Scripts
2
kv> load –file <path to script>
7 - 18
Loading Data Into Tables
7 - 19
Write Operations: put() Methods
7 - 20
Writing Rows to Tables: Steps
7 - 21
Reading Data from Tables
7 - 22
Read Operations: get() Methods
7 - 23
Removing Data From Tables
7 - 24
Delete Operations: 3 TableAPIs
7 - 25
Summary
7 - 26