IP Library › Granted Patent US 12,493,592
Granted Patent B2
US 12,493,592 · App. 18/891,633 · Granted Dec 9, 2025

Constraint relationship check methods and apparatuses for database

Inventors: Zhenkun Yang (Beijing, CN); Fusheng Han (Beijing, CN); Yuchen Wei (Beijing, CN); Fanyu Kong (Beijing, CN)
Assignee: Beijing OceanBase Technology Co., Ltd.
G06F16/217G06F16/219
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,493,592
App. No.
18/891,633
Granted
Dec 9, 2025
Kind
B2
Abstract

A computer-implemented method for a database constraint relationship check, includes performing a data manipulation language (DML) operation of a first transaction for a target data table in the database. A submission stage is entered. A corresponding current transaction version number is determined for a target data record obtained and each latest related data record visible to the first transaction is read from the target data table or an associated data table of the target data table. A mutual limitation relationship exists between field values corresponding to a target field in the target data record and each related data record. A constraint relationship check is performed on a target field value corresponding to the target field in the target data record based on each related data record. The first transaction is submitted if the constraint relationship check succeeds or the first transaction is rolled back otherwise.

Claims (86)

1 . A computer-implemented method for a database constraint relationship check, comprising:

performing a data manipulation language (DML) operation of a first transaction for a target data table in a database, wherein each data record stored in each data table in the database has a transaction version number;

entering a submission stage;

determining a corresponding current transaction version number for a target data record obtained after the DML operation in the submission stage;

reading each latest related data record visible to the first transaction from the target data table or an associated data table of the target data table based on the corresponding current transaction version number, wherein there is a mutual limitation relationship between field values corresponding to a target field in the target data record and each related data record;

performing a constraint relationship check on a target field value corresponding to the target field in the target data record based on each related data record; and

submitting the first transaction if the constraint relationship check succeeds or rolling back the first transaction otherwise.

2 . The computer-implemented method of claim 1 , wherein:

the DML operation comprises one of: an addition operation, a modification operation, and a deletion operation.

3 . The computer-implemented method of claim 1 , wherein:

a constraint relationship is a unique constraint or a primary key constraint; and

the reading each latest related data record visible to the first transaction, comprises:

reading, from the target data table as the related data record, each latest data record, wherein a corresponding transaction version number of each latest data record is less than or equal to a current transaction version number.

4 . The computer-implemented method of claim 1 , wherein:

a constraint relationship is a foreign key constraint; and

the reading each latest related data record visible to the first transaction, comprises:

reading, from the associated data table of the target data table as the related data record, each latest data record, wherein a corresponding transaction version number of each latest data record is less than or equal to a current transaction version number.

5 . The computer-implemented method of claim 4 , wherein:

the associated data table is a child table of the target data table if the DML operation is a deletion operation; or

the associated data table is a parent table of the target data table if the DML operation is an addition operation or a modification operation.

6 . The computer-implemented method of claim 1 , wherein:

a constraint relationship is a unique constraint or a primary key constraint; and

the performing a constraint relationship check on a target field value corresponding to the target field in the target data record, comprises:

matching the target field value with each field value corresponding to the target field in each related data record in the target data table, wherein the constraint relationship check succeeds if matching with all the field values fails; or the constraint relationship check fails otherwise.

7 . The computer-implemented method of claim 1 , wherein:

a constraint relationship is a foreign key constraint; and

the performing a constraint relationship check on a target field value corresponding to the target field in the target data record, comprises:

matching the target field value with each field value corresponding to the target field in each related data record in a child table of the target data table if the DML operation is a deletion operation, wherein the constraint relationship check succeeds if matching with all the field values fails; or the constraint relationship check fails otherwise; or

matching the target field value with each field value corresponding to the target field in each related data record in a parent table of the target data table if the DML operation is an addition operation or a modification operation, wherein the constraint relationship check succeeds if the target field value is successfully matched with any field value; or the constraint relationship check fails otherwise.

8 . The computer-implemented method of claim 1 , wherein:

the determining a corresponding current transaction version number, comprises:

determining a globally ordered transaction ID of the first transaction as the current corresponding transaction version number.

9 . The computer-implemented method of claim 1 , wherein:

the DML operation is an addition operation or a modification operation, and comprising:

adding the current corresponding transaction version number to the target data record if the constraint relationship check succeeds, to obtain an updated target data record; and

storing the updated target data record in the target data table.

10 . The computer-implemented method of claim 1 , wherein:

a check occasion of a constraint relationship is an immediate check; and

comprising:

immediately performing the constraint relationship check on the target field value corresponding to the target field in the target data record before the submission stage is entered.

11 . A non-transitory, computer-readable medium storing one or more instructions executable by a computer system to perform one or more operations for a database constraint relationship check, comprising:

performing a data manipulation language (DML) operation of a first transaction for a target data table in a database, wherein each data record stored in each data table in the database has a transaction version number;

entering a submission stage;

determining a corresponding current transaction version number for a target data record obtained after the DML operation in the submission stage;

reading each latest related data record visible to the first transaction from the target data table or an associated data table of the target data table based on the corresponding current transaction version number, wherein there is a mutual limitation relationship between field values corresponding to a target field in the target data record and each related data record;

performing a constraint relationship check on a target field value corresponding to the target field in the target data record based on each related data record; and

submitting the first transaction if the constraint relationship check succeeds or rolling back the first transaction otherwise.

12 . The non-transitory, computer-readable medium of claim 11 , wherein:

the DML operation comprises one of: an addition operation, a modification operation, and a deletion operation.

13 . The non-transitory, computer-readable medium of claim 11 , wherein:

a constraint relationship is a unique constraint or a primary key constraint; and

the reading each latest related data record visible to the first transaction, comprises:

reading, from the target data table as the related data record, each latest data record, wherein a corresponding transaction version number of each latest data record is less than or equal to a current transaction version number.

14 . The non-transitory, computer-readable medium of claim 11 , wherein:

a constraint relationship is a foreign key constraint; and

the reading each latest related data record visible to the first transaction, comprises:

reading, from the associated data table of the target data table as the related data record, each latest data record, wherein a corresponding transaction version number of each latest data record is less than or equal to a current transaction version number.

15 . The non-transitory, computer-readable medium of claim 14 , wherein:

the associated data table is a child table of the target data table if the DML operation is a deletion operation; or

the associated data table is a parent table of the target data table if the DML operation is an addition operation or a modification operation.

16 . The non-transitory, computer-readable medium of claim 11 , wherein:

a constraint relationship is a unique constraint or a primary key constraint; and

the performing a constraint relationship check on a target field value corresponding to the target field in the target data record, comprises:

matching the target field value with each field value corresponding to the target field in each related data record in the target data table, wherein the constraint relationship check succeeds if matching with all the field values fails; or the constraint relationship check fails otherwise.

17 . The non-transitory, computer-readable medium of claim 11 , wherein:

a constraint relationship is a foreign key constraint; and

the performing a constraint relationship check on a target field value corresponding to the target field in the target data record, comprises:

matching the target field value with each field value corresponding to the target field in each related data record in a child table of the target data table if the DML operation is a deletion operation, wherein the constraint relationship check succeeds if matching with all the field values fails; or the constraint relationship check fails otherwise; or

matching the target field value with each field value corresponding to the target field in each related data record in a parent table of the target data table if the DML operation is an addition operation or a modification operation, wherein the constraint relationship check succeeds if the target field value is successfully matched with any field value; or the constraint relationship check fails otherwise.

18 . The non-transitory, computer-readable medium of claim 11 , wherein:

the determining a corresponding current transaction version number, comprises:

determining a globally ordered transaction ID of the first transaction as the current corresponding transaction version number.

19 . The non-transitory, computer-readable medium of claim 11 , wherein:

the DML operation is an addition operation or a modification operation, and

comprising:

adding the current corresponding transaction version number to the target data record if the constraint relationship check succeeds, to obtain an updated target data record; and

storing the updated target data record in the target data table.

20 . A computer-implemented system, comprising:

one or more computers; and

one or more computer memory devices interoperably coupled with the one or more computers and having tangible, non-transitory, machine-readable media storing one or more instructions that, when executed by the one or more computers, perform one or more operations for a database constraint relationship check, comprising:

performing a data manipulation language (DML) operation of a first transaction for a target data table in a database, wherein each data record stored in each data table in the database has a transaction version number;

entering a submission stage;

determining a corresponding current transaction version number for a target data record obtained after the DML operation in the submission stage;

reading each latest related data record visible to the first transaction from the target data table or an associated data table of the target data table based on the corresponding current transaction version number, wherein there is a mutual limitation relationship between field values corresponding to a target field in the target data record and each related data record;

performing a constraint relationship check on a target field value corresponding to the target field in the target data record based on each related data record; and

submitting the first transaction if the constraint relationship check succeeds or rolling back the first transaction otherwise.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Oct 14, 2024
From: YANG, ZHENKUN; HAN, FUSHENG; WEI, YUCHEN; KONG, FANYU
To: BEIJING OCEANBASE TECHNOLOGY CO., LTD.
Reel/Frame 069173/0483 →
Priority Claims (1)
CN 202210340354.5 · Apr 2, 2022 · national
Continuity (2)
Continuation PCTCN2023085452 · Mar 31, 2023
Related Publication 20250013617A1 · Jan 9, 2025
References Cited (21)
US 7836028B1 · Agarwal · 2010 [cited by examiner]
US 10216820B1 · Holenstein · 2019 [cited by examiner]
US 12001314B2 · Dickinson · 2024 [cited by examiner]
US 20160210316A1 · Bendel · 2016 [cited by examiner]
US 20190129986A1 · Birn · 2019 [cited by examiner]
US 20220035652A1 · Stamos · 2022 [cited by examiner]
US 20220171748A1 · Bamel · 2022 [cited by examiner]
US 20230081900A1 · Werner · 2023 [cited by examiner]
CN 1645372A · 2005 [cited by applicant]
CN 103714090A · 2014 [cited by applicant]
CN 104252382A · 2014 [cited by applicant]
CN 105868228A · 2016 [cited by applicant]
CN 107025257A · 2017 [cited by applicant]
CN 110019530A · 2019 [cited by applicant]
CN 110059115A · 2019 [cited by applicant]
CN 111259071A · 2020 [cited by applicant]
CN 114428774A · 2022 [cited by applicant]
CN 117076547A · 2023 [cited by applicant]
WO WO2021073571A1 · 2021 [cited by applicant]
International Preliminary Report on Patentability in International Appln. No. PCT /CN2023/085452, mailed on Oct. 17, 2024, 12 pages (with English translation). [cited by applicant]
International Search Report and Written Opinion in International Appln. No. PCT /CN2023/085452, mailed on Jun. 25, 2 2023, 14 pages (with English translation). [cited by applicant]