Managing Database and Table Grouping
NineData uses database and table grouping to help you manage sharded databases for query, data change, and replication workflows. This article explains how to create, update, and delete database groups and table groups.
Before you begin
Sign in to the NineData Console with an account that can manage data sources in the current organization.
Procedure
Creating a Database Group
Log in to the NineData Console.
Go to Datasource > Datasource.
Click the Database Grouping tab, and then click Create Database Grouping.
Configure the form using the table, and then click Create Database Grouping.
Parameter Description Database Grouping Name Enter a database group name. The name supports only letters, numbers, and underscores, and must start with a letter. Use a meaningful name so the group is easy to identify later. Description(Optional) Enter a business description for this database group. Environment Select the environment that contains the data sources for this group. Database Click Add Datasource and add data sources. - Datasource: Select one or more data sources. You can search by data source name, select all, or clear selected items.
- Database Expression: Enter a database expression. NineData scans the selected data sources and extracts databases that match the expression. For expression syntax, see the Appendix.
After the database group is created, it defaults to the SQL development standards and approval processes configured in the environment it belongs to. You can change them based on your business needs.
Creating a Table Group
Log in to the NineData Console.
Go to Datasource > Datasource.
Click the Database Grouping tab, and click the name of the target database group, or click the
Details in the Actions column on the right side of the database group.
On the Database Grouping Detail page, click Create Table Grouping.
Configure the form using the table, and then click Create Table Grouping.
Parameter Description Table Grouping Name Enter a table group name. The name supports only letters, numbers, and underscores, and must start with a letter. Use a meaningful name so the group is easy to identify later. Methods Supports Add Manually and Add by Expression. Add by Expression Required when Methods is set to Add by Expression. Enter an expression and click Auto Fetch. NineData scans the target databases and extracts tables that match the expression. For expression syntax, see the Appendix. Routing Algorithm(Optional) Available when Methods is set to Add by Expression. Configure the same routing algorithm used by your application so NineData can route queries to the required tables more efficiently. Database Required when Methods is set to Add Manually. Click Add Datasource and select one or more data sources. You can search by data source name, select all, or clear selected items. After you click OK, select the required databases and tables. Depending on the data source type, you may also need to select schemas. tipTo use Routing Algorithm for direct routing and avoid scanning all sharded databases and tables, all of the following conditions must be met:
- The table group is created by an expression, not manually selected.
- Routing Algorithm is configured during table group creation and matches the routing algorithm used by your application.
- The query uses an equality condition on the routing field in the
WHEREclause.
Removing a Table Group
If the data structure changes or the grouping configuration is no longer suitable, remove the current table group and create a new one.
Log in to the NineData Console.
Go to Datasource > Datasource.
Click the Database Grouping tab, and click the name of the target database group, or click the
Details in the Actions column on the right side of the database group.
On the Database Grouping Detail page, click the Table Grouping tab, click the
Remove under the Actions column on the right side of the target table group to be removed, and then click OK.
Deleting a Database Group
Log in to the NineData Console.
Go to Datasource > Datasource.
Click the Database Grouping tab, and click the
Delete under the Actions column on the right side of the target database group to be deleted, and then click OK.
tipIf the current database group is associated with unfinished replication tasks, the database group cannot be deleted. You need to find and terminate the corresponding replication tasks and try to delete the database group again.
Result
Database groups and table groups are updated on the database grouping tab. You can use the updated grouping when managing data sources and related database permissions.