An adaptive SQL differential privacy noise adding method
By adaptively allocating privacy budgets and adding noise according to SQL query characteristics, the balance of privacy protection and data utility in complex SQL queries is solved, and the optimal privacy protection effect and high accuracy are achieved.
Patent Information
- Application Number
- CN202411708117.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-11-27
AI Technical Summary
In complex SQL queries, how to accurately calculate and add appropriate amount of noise to achieve the optimal privacy protection effect while minimizing the impact on data utility as much as possible has become a technical difficulty.
It provides an adaptive SQL differential privacy noise-adding method. According to the characteristics of SQL queries, such as the type of aggregate function, the complexity of the query, and the sensitivity of the data, it dynamically allocates the privacy budget, and introduces noise into the query results to achieve privacy protection.
By dynamically allocating privacy budgets and adding noise, we can effectively protect data privacy in complex SQL queries while maximizing the accuracy and availability of query results, achieving the optimal privacy protection effect.
Smart Images

Figure CN119201981B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data protection technology, and in particular to an adaptive SQL differential privacy noise adding method. Background Art
[0002] With the prevalence of big data and cloud computing, multi-source heterogeneous database environments have become the norm for data collection, storage, and analysis, which include data sets from different sources, formats, and structures, such as relational databases, NoSQL databases, file systems, etc. Data queries in this environment, especially the execution of complex SQL statements, pose severe challenges to data privacy protection. Complex SQL statements, which usually involve multi-table joins, subqueries, aggregate functions, etc., not only increase the semantic complexity of queries, but also make it extremely difficult to accurately assess the impact of queries on sensitive data, thereby amplifying the potential risk of privacy leakage. For example, a query containing multiple JOIN and GROUP BY operations may inadvertently leak a large amount of private information. How to effectively protect data privacy while maintaining the practicality of data and the accuracy of analysis results when executing such statements has become a key issue that needs to be solved urgently.
[0003] Differential privacy is an effective privacy protection technology that protects individual privacy by adding an appropriate amount of random noise to the query results to ensure that the query results do not change much when including or excluding a certain individual's data. However, how to accurately calculate and add the appropriate amount of noise in complex SQL statements to achieve the best privacy protection effect while minimizing the impact on data utility is a technical difficulty. Therefore, it is crucial to develop a method that can adjust privacy protection parameters according to specific query situations. Summary of the invention
[0004] In response to the needs and shortcomings of current technological development, the present invention provides an adaptive SQL differential privacy noising method, which dynamically allocates the privacy budget according to the characteristics of SQL queries, such as the type of aggregation function, the complexity of the query, and the sensitivity of the data, thereby maximizing the accuracy and availability of the query results while achieving privacy protection.
[0005] The present invention provides an adaptive SQL differential privacy noise adding method, which solves the above technical problems and adopts the following technical solutions:
[0006] An adaptive SQL differential privacy noise adding method, the implementation of which includes the following four stages:
[0007] S1. Metadata management stage: regularly collect and update the metadata of the database, analyze the attribute characteristics of the data table, form a data attribute characteristic library, combine the identification of the attribute characteristics of the data table in the data attribute characteristic library, analyze the impact caused by the leakage and damage of the data, and form a data sensitivity library corresponding to the database;
[0008] S2, feature extraction stage: rewrite the received SQL query request into an abstract syntax tree, traverse the abstract syntax tree, record the type of aggregate function and its associated fields and conditions; identify the multi-table connection query structure and multi-layer sub-query structure, determine the connection mode of the tables involved in the query and the structure and hierarchy of the sub-query nodes;
[0009] S3, privacy budget analysis and decision stage: bind the key semantic information contained in the SQL query request with the sensitivity of each data table and data item in the data sensitivity library; calculate the sensitivity φ of the SQL query request based on the characteristics of the SQL query request and the sensitivity of the bound related data tables and data items, and adaptively allocate a suitable privacy budget ∈ to the SQL query request according to the sensitivity φ;
[0010] S4, noise introduction stage: set a maximum privacy budget for each data table and data item in the database, check whether the privacy budget margin of the data table and data item corresponding to the SQL query request is sufficient, if so, use the data perturbation mechanism that satisfies ∈-differential privacy to perturb the query result and obtain the perturbed result, if not, reject the SQL query request.
[0011] Optionally, the step S1 involved specifically includes:
[0012] S1.1. Regularly collect and update the metadata of the database, including the name of the data table, field type and constraints;
[0013] S1.2. Analyze the attribute characteristics of the data table, combine the data characteristics, identify the eight elements of the data involved, namely, field, group, region, accuracy, scale, depth, coverage and importance, and form a data attribute feature library;
[0014] S1.3. Analyze the impact of data leakage, tampering, damage, or illegal acquisition, illegal use, or illegal sharing based on the identification of data table attribute features in the data attribute feature library;
[0015] S1.4. Determine the sensitivity of each data table and data item in the database according to the impact degree, and form a data sensitivity library corresponding to the database.
[0016] Further optionally, in the process of executing step S1.2 to form a data attribute feature library:
[0017] Identify the four elements of the data description: industry, business line, process link and content theme;
[0018] Identify the six group elements described by the data: people, organizations, networks and information systems, resources, equipment, and projects;
[0019] Identify the two regional elements of the administrative division and designated area described by the data;
[0020] Identify the four accuracy factors of numerical accuracy, spatial accuracy, temporal accuracy and process precision;
[0021] Identify the three scale factors of data storage, group size, and regional size;
[0022] Identify the deep elements of data in describing the economic operation, development trend, whereabouts, activity records and object relationships of the object;
[0023] Identify the two coverage factors of data, namely, the percentage and distribution of coverage of fields, groups, regions, and time periods;
[0024] Identify the importance of data in the five aspects of economic development, political development, cultural development, social development and ecological civilization construction.
[0025] Optionally, the impact levels mentioned in step S1.3 are divided into particularly serious hazards, serious hazards, and general hazards from high to low;
[0026] Before determining the extent of impact, first specify the criteria for determination.
[0027] Optionally, the step S2 involved specifically includes:
[0028] S2.1. Rewrite the received SQL query request into an abstract syntax tree, traverse the abstract syntax tree, find the aggregate function nodes therein, record the found aggregate function types, and extract the fields and conditions associated with these aggregate functions;
[0029] S2.2, identifying a multi-table join query structure, analyzing the FROM clause and the JOIN clause in the abstract syntax tree, determining the number of tables involved in the query and the connection mode between the tables, wherein the connection mode includes an inner join and a left join;
[0030] S2.3. Identify a multi-layer sub-query structure, recursively traverse the abstract syntax tree, find sub-query nodes, analyze the structure and hierarchy of the sub-query nodes, and record the types and dependencies of the sub-query nodes.
[0031] Optionally, the step S3 involved specifically includes:
[0032] S3.1. Access the data sensitivity library corresponding to the target database, and bind the key semantic information contained in the SQL query request with the sensitivity of each data table and data item in the data sensitivity library corresponding to the database;
[0033] S3.2, based on the aggregate function, multi-table connection query structure, multi-layer subquery structure extracted from the SQL query request, and the sensitivity of each bound data table and data item, sensitivity calculation is performed to obtain the sensitivity φ of the SQL query request, and the sensitivity φ is used to add data noise to the SQL query result;
[0034] S3.3. Select K alternative privacy budgets, use the data perturbation mechanism that satisfies differential privacy to perturb the SQL query results respectively, and obtain K perturbed query results; repeat this process T times, and then evaluate the average perturbation effect corresponding to the K privacy budgets, and allocate a suitable privacy budget ∈ to the SQL query request with sensitivity φ.
[0035] Further optionally, execute step S3.3, and repeat the process of "selecting K alternative privacy budgets, perturbing the SQL query results respectively using the data perturbation mechanism that satisfies differential privacy, and obtaining K perturbed query results" T times, and selecting a specific privacy budget for noise addition each time, wherein a privacy budget is selected and noise addition is performed using at least one of the random principle, the average principle, the maximum minimization principle, the minimum maximization principle, the principle based on historical data, the dynamic adjustment principle, the user preference principle, and the cost-effectiveness principle.
[0036] Optionally, the step S4 involved specifically includes:
[0037] S4.1. Set a maximum privacy budget for each data table and data item in the database, and perform privacy control on multiple query requests through the set maximum privacy budget;
[0038] S4.2. Check whether the privacy budget margin of the data table and data item corresponding to the SQL query request is sufficient. If the privacy budget is insufficient, reject the query request or return a corresponding error message. If the privacy budget is sufficient, execute the SQL query request to obtain the query result Q, and then update the privacy budget margin of the data table and data item by deducting the privacy budget ∈, where:
[0039] (a) For numerical data, the query result Q is perturbed using a data perturbation mechanism that satisfies ∈-differential privacy, and the perturbed result D is obtained;
[0040] (b) For non-numeric data, the non-numeric data is converted into a feature vector, and the privacy information of the feature vector is protected by using a data perturbation mechanism that satisfies ∈-differential privacy.
[0041] Preferably, step S4.1 is executed to set a unified maximum privacy budget for each data table and data item in the database, or, based on the data sensitivity library, a maximum privacy budget is set for each data table and data item in the database.
[0042] Compared with the prior art, the adaptive SQL differential privacy noise adding method of the present invention has the following beneficial effects:
[0043] The present invention can accurately calculate and dynamically allocate the privacy budget according to the characteristics of complex SQL queries, such as the type of aggregation function, the complexity of the query, and the sensitivity of the data, and add an appropriate amount of noise to the query results, thereby maximizing the accuracy and availability of the query results while achieving privacy protection, thereby achieving the best privacy protection effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Attached Figure 1 It is a flow chart of the method of embodiment 1 of the present invention. DETAILED DESCRIPTION
[0045] In order to make the technical solution, the technical problem solved and the technical effect of the present invention more clearly understood, the technical solution of the present invention is clearly and completely described below in conjunction with specific embodiments.
[0046] Embodiment 1:
[0047] Combined with Figure 1 This embodiment proposes an adaptive SQL differential privacy noise adding method, the implementation of which includes the following four stages:
[0048] S1. Metadata management stage:
[0049] S1.1. Regularly collect and update the metadata of the database, including the name of the data table, field type and constraints;
[0050] S1.2. Analyze the attribute characteristics of the data table, and identify the eight elements involved in the data, including the field, group, region, precision, scale, depth, coverage and importance, in combination with the characteristics of the data, to form a data attribute feature library. In this process, specifically identify: (a) the four field elements of the industry field, business line, process link and content theme described by the data; (b) the six group elements of the population, organization, network and information system, resource, equipment and project described by the data; (c) the two regional elements of the administrative division and designated area described by the data; (d) the four precision elements of numerical precision, spatial precision, temporal precision and process precision; (e) the three scale elements of data storage volume, group scale and regional scale; (f) the five depth elements of the data in describing the economic operation, development trend, whereabouts, activity records and object relationship of the described object; (g) the two coverage elements of the data coverage ratio and coverage distribution of the field, group, region and time period; (h) the five importance elements of the data in economic construction, political construction, cultural construction, social construction and ecological civilization construction;
[0051] S1.3. Combined with the identification of the data table attribute features in the data attribute feature library, analyze the impact caused by data leakage, tampering, damage, or illegal acquisition, illegal use, and illegal sharing; generally speaking, the impact is divided into particularly serious harm, serious harm, and general harm from high to low; before judging the impact, first specify the judgment basis: (a) When judging the impact on national security, economic operation, social order or public interests, the overall interests of the country, society or industry are used as the basis for judging the impact. (b) When judging the impact on the rights and interests of organizations or individuals, the rights and interests of organizations or individual citizens are used as the basis for judging the impact;
[0052] S1.4. Determine the sensitivity of each data table and data item in the database according to the impact degree, and form a data sensitivity library corresponding to the database.
[0053] S2, feature extraction stage:
[0054] S2.1. Rewrite the received SQL query request into an abstract syntax tree, traverse the abstract syntax tree, find the aggregation function nodes such as COUNT(), SUM(), AVG(), MAX(), MIN(), etc., record the found aggregation function types, and extract the fields and conditions associated with these aggregation functions; it should be added that different aggregation functions have different impacts on data privacy. For example, for the AVG function involving sensitive average calculation, more privacy budget may need to be allocated to ensure the accuracy of the result, while for the COUNT function, since it calculates the number of sensitive data records, less privacy budget is required to ensure the security of sensitive data;
[0055] S2.2, identifying a multi-table join query structure, analyzing the FROM clause and the JOIN clause in the abstract syntax tree, determining the number of tables involved in the query and the connection mode between the tables, wherein the connection mode includes an inner join and a left join;
[0056] S2.3. Identify a multi-layer sub-query structure, recursively traverse the abstract syntax tree, find sub-query nodes, analyze the structure and hierarchy of the sub-query nodes, and record the types and dependencies of the sub-query nodes.
[0057] S3, Privacy budget analysis and decision-making stage:
[0058] S3.1. Access the data sensitivity library corresponding to the target database, and bind the key semantic information (such as table name and field name) contained in the SQL query request with the sensitivity of each data table and data item in the data sensitivity library corresponding to the database;
[0059] S3.2, based on the aggregate function, multi-table connection query structure, multi-layer subquery structure extracted from the SQL query request, and the sensitivity of each bound data table and data item, sensitivity calculation is performed to obtain the sensitivity φ of the SQL query request, and the sensitivity φ is used to add data noise to the SQL query result;
[0060] What needs to be added in this step is that, first, assume that the following features are extracted from the SQL query request: ① Aggregation functions: such as SUM, COUNT, AVG, etc., ② Multi-table joins: identify the type of JOIN operation (INNER JOIN, LEFT JOIN, etc.), ③ Multi-layer subqueries: identify the hierarchy and structure of nested subqueries. Subsequently, the extracted features are bound to the data attribute feature library and the data sensitivity library. For the sensitivity of data tables and fields, each data table and field has a predefined sensitivity score. For the sensitivity of operation types, different types of operations (such as aggregation, join, subquery) have different sensitivity weights. Then, the sensitivity φ is comprehensively calculated by weighted summation or machine learning algorithm: (A) Weighted summation method: assign a weight to each feature, and calculate the total sensitivity based on the occurrence of the feature. The formula involved is φ=∑(w i ×s i ), where w i is the weight of the i-th feature, s i is the sensitivity score of the feature; (B) Machine learning algorithm: Use the trained model to predict the sensitivity of the query request. The model can be based on decision tree, random forest, SVM, etc.
[0061] S3.3. Select K alternative privacy budgets, use the data perturbation mechanism that satisfies differential privacy to perturb the SQL query results respectively, and obtain K perturbed query results; repeat this process T times, and then evaluate the average perturbation effect corresponding to the K privacy budgets, and allocate a suitable privacy budget ∈ to the SQL query request with sensitivity φ.
[0062] Execute step S3.3, and repeat the process of "selecting K alternative privacy budgets, perturbing the SQL query results respectively using the data perturbation mechanism that satisfies differential privacy, and obtaining K perturbed query results" T times, and selecting a privacy budget for noise addition each time. Among them, a privacy budget is selected and noise addition is performed using at least one of the random principle, average principle, maximum minimization principle, minimum maximization principle, principle based on historical data, dynamic adjustment principle, user preference principle and cost-effectiveness principle.
[0063] S4, noise introduction stage:
[0064] S4.1. Set a maximum privacy budget for each data table and data item in the database, and perform privacy control on multiple query requests through the set maximum privacy budget; specifically, a unified maximum privacy budget can be set for each data table and data item in the database, or, based on the data sensitivity library, a maximum privacy budget can be set for each data table and data item in the database;
[0065] S4.2. Check whether the privacy budget margin of the data table and data item corresponding to the SQL query request is sufficient. If the privacy budget is insufficient, reject the query request or return a corresponding error message. If the privacy budget is sufficient, execute the SQL query request to obtain the query result Q, and then update the privacy budget margin of the data table and data item by deducting the privacy budget ∈, where:
[0066] (a) For numerical data, the query result Q is perturbed using a data perturbation mechanism that satisfies ∈-differential privacy, and the perturbed result D is obtained;
[0067] (b) For non-numeric data, such as multimedia data such as text or images, the non-numeric data is converted into a feature vector, and the privacy information of the feature vector is protected by using a data perturbation mechanism that satisfies ∈-differential privacy.
[0068] In summary, the adaptive SQL differential privacy noise adding method of the present invention can accurately calculate the dynamic allocation of privacy budget according to the characteristics of complex SQL queries, and add a suitable amount of noise to the query results, thereby maximizing the accuracy and availability of the query results while achieving privacy protection, and achieving the best privacy protection effect.
[0069] The above specific examples are used to explain the principles and implementation methods of the present invention in detail. These examples are only used to help understand the core technical content of the present invention. Based on the above specific embodiments of the present invention, any improvements and modifications made by technicians in this technical field without departing from the principles of the present invention should fall within the scope of patent protection of the present invention.
Claims
1. An adaptive SQL differential privacy noise adding method, characterized in that: Its implementation includes the following four stages: S1. Metadata management stage: regularly collect and update the metadata of the database, analyze the attribute characteristics of the data table, form a data attribute characteristic library, combine the identification of the attribute characteristics of the data table in the data attribute characteristic library, analyze the impact caused by the leakage and damage of the data, and form a data sensitivity library corresponding to the database; S2, feature extraction stage: rewrite the received SQL query request into an abstract syntax tree, traverse the abstract syntax tree, and record the aggregation function type and its associated fields and conditions; Identify multi-table join query structures and multi-layer subquery structures, determine how the tables involved in the query are joined, and the structure and hierarchy of the subquery nodes; S3, privacy budget analysis and decision stage: binding the key semantic information contained in the SQL query request with the sensitivity of each data table and data item in the data sensitivity library; Based on the characteristics of the SQL query request and the sensitivity of the bound related data tables and data items, the sensitivity φ of the SQL query request is calculated, and the appropriate privacy budget ∈ is adaptively allocated to the SQL query request according to the sensitivity φ; this process specifically includes: S3.
1. Access the data sensitivity library corresponding to the target database, and bind the key semantic information contained in the SQL query request with the sensitivity of each data table and data item in the data sensitivity library corresponding to the database; S3.2, based on the aggregate function, multi-table connection query structure, multi-layer subquery structure extracted from the SQL query request, and the sensitivity of each bound data table and data item, sensitivity calculation is performed to obtain the sensitivity φ of the SQL query request, and the sensitivity φ is used to add data noise to the SQL query result; S3.
3. Select K alternative privacy budgets, use the data perturbation mechanism that satisfies differential privacy to perturb the SQL query results respectively, and obtain K perturbed query results; repeat this process T times, then evaluate the average perturbation effect corresponding to the K privacy budgets, and allocate a suitable privacy budget ∈ to the SQL query request with sensitivity φ; S4, noise introduction stage: set a maximum privacy budget for each data table and data item in the database, check whether the privacy budget margin of the data table and data item corresponding to the SQL query request is sufficient, if so, use the data perturbation mechanism that satisfies ∈-differential privacy to perturb the query result and obtain the perturbed result, if not, reject the SQL query request.
2. According to claim 1, an adaptive SQL differential privacy noise adding method is characterized in that: The step S1 specifically includes: S1.
1. Regularly collect and update the metadata of the database, including the name of the data table, field type and constraints; S1.
2. Analyze the attribute characteristics of the data table, combine the data characteristics, identify the eight elements of the data involved, namely, field, group, region, accuracy, scale, depth, coverage and importance, and form a data attribute feature library; S1.
3. Analyze the impact of data leakage, tampering, damage, or illegal acquisition, illegal use, or illegal sharing based on the identification of data table attribute features in the data attribute feature library; S1.
4. Determine the sensitivity of each data table and data item in the database according to the impact degree, and form a data sensitivity library corresponding to the database.
3. According to claim 2, an adaptive SQL differential privacy noise adding method is characterized in that: In the process of executing step S1.2 to form a data attribute feature library: Identify the four elements of the data description: industry, business line, process link and content theme; Identify the six group elements described by the data: people, organizations, networks and information systems, resources, equipment, and projects; Identify the two regional elements of the administrative division and designated area described by the data; Identify the four accuracy factors of numerical accuracy, spatial accuracy, temporal accuracy and process precision; Identify the three scale factors of data storage, group size, and regional size; Identify the deep elements of data in describing the economic operation, development trend, whereabouts, activity records and object relationships of the object; Identify the two coverage factors of data, namely, the percentage and distribution of coverage of fields, groups, regions, and time periods; Identify the importance of data in the five aspects of economic development, political development, cultural development, social development and ecological civilization construction.
4. According to claim 2, an adaptive SQL differential privacy noise adding method is characterized in that: The impact levels mentioned in step S1.3 are classified from high to low into particularly serious hazards, serious hazards, and general hazards; Before determining the extent of impact, first specify the criteria for determination.
5. The adaptive SQL differential privacy noise adding method according to claim 1, characterized in that: The step S2 specifically includes: S2.
1. Rewrite the received SQL query request into an abstract syntax tree, traverse the abstract syntax tree, find the aggregate function nodes therein, record the found aggregate function types, and extract the fields and conditions associated with these aggregate functions; S2.2, identifying a multi-table join query structure, analyzing the FROM clause and the JOIN clause in the abstract syntax tree, determining the number of tables involved in the query and the connection mode between the tables, wherein the connection mode includes an inner join and a left join; S2.
3. Identify a multi-layer sub-query structure, recursively traverse the abstract syntax tree, find sub-query nodes, analyze the structure and hierarchy of the sub-query nodes, and record the types and dependencies of the sub-query nodes.
6. The adaptive SQL differential privacy noise adding method according to claim 1, characterized in that: Execute step S3.3, and repeat the process of "selecting K alternative privacy budgets, perturbing the SQL query results respectively using the data perturbation mechanism that satisfies differential privacy, and obtaining K perturbed query results" T times, and selecting a privacy budget for noise addition each time. Among them, a privacy budget is selected and noise addition is performed using at least one principle selected from the random principle, the average principle, the maximum minimization principle, the minimum maximization principle, the principle based on historical data, the dynamic adjustment principle, the user preference principle, and the cost-effectiveness principle.
7. The adaptive SQL differential privacy noise adding method according to claim 1, characterized in that: The step S4 specifically includes: S4.
1. Set a maximum privacy budget for each data table and data item in the database, and perform privacy control on multiple query requests through the set maximum privacy budget; S4.
2. Check whether the privacy budget margin of the data table and data item corresponding to the SQL query request is sufficient. If the privacy budget is insufficient, reject the query request or return a corresponding error message. If the privacy budget is sufficient, execute the SQL query request to obtain the query result Q, and then update the privacy budget margin of the data table and data item by deducting the privacy budget ∈, where: (a) For numerical data, the query result Q is perturbed using a data perturbation mechanism that satisfies ∈-differential privacy, and the perturbed result D is obtained; (b) For non-numeric data, the non-numeric data is converted into a feature vector, and the privacy information of the feature vector is protected by using a data perturbation mechanism that satisfies ∈-differential privacy.
8. The adaptive SQL differential privacy noise adding method according to claim 7, characterized in that: Execute step S4.1 to set a unified maximum privacy budget for each data table and data item in the database, or, based on the data sensitivity library, set a maximum privacy budget for each data table and data item in the database.
Citation Information
Patent Citations
Privacy budget allocating and data publishing method and privacy budget allocating and data publishing system for protecting data query privacy
CN108537055A
Data warehouse star connection query method and system based on differential privacy and medium
CN115858579A