Updated on 2024-04-02 GMT+08:00

Typical Scenario Description

Based on typical scenarios, users can quickly learn and master the HBase development process and know important interface functions.

Scenario

Develop an application to manage information about users who use service A in an enterprise. Table 1 provides the user information. The operation process of service A is described as follows:

  • Create a user information table.
  • Add diplomas and titles to the user information table.
  • Query user names and addresses by user ID.
  • Query information by user name.
  • Query information about users whose ages range from 20 to 29.
  • Collect statistics on the number and the maximum, minimum, and average ages of users.
  • Deregister users, and delete user data.
  • Delete the user information table after service A ends.
    Table 1 User information

    ID

    Name

    Gender

    Age

    Address

    12005000201

    Zhang San

    Male

    19

    Shenzhen, Guangdong

    12005000202

    Li Wanting

    Female

    23

    Shijiazhuang, Hebei

    12005000203

    Wang Ming

    Male

    26

    Ningbo, Zhejiang

    12005000204

    Li Gang

    Male

    18

    Xiangyang, Hubei

    12005000205

    Zhao Enru

    Female

    21

    Shangrao, Jiangxi

    12005000206

    Chen Long

    Male

    32

    Zhuzhou, Hunan

    12005000207

    Zhou Wei

    Female

    29

    Nanyang, Henan

    12005000208

    Yang Yiwen

    Female

    30

    Kaixian, Chongqing

    12005000209

    Xu Bing

    Male

    26

    Weinan, Shaanxi

    12005000210

    Xiao Kai

    Male

    25

    Dalian, Liaoning

Data Planning

Proper design of the table structure, RowKeys, and column names can give full play to the advantages of HBase. In this example, the unique ID is used as the RowKey, and columns are stored in the info column family.

HBase tables are stored in Namespace:Table name format. If no namespace is specified when a table is created, the table is stored in default. The hbase namespace is the system table namespace. Do not create service tables or read or write data in the system table namespace.