A database automatic design method and system based on a large language model
By using large language models and chained reasoning prompts for engineering templates, the system automatically parses natural language requirements to generate database models and performs normalization checks. This solves the problem that existing tools cannot directly generate ER diagrams and relational models, and achieves efficient, accurate, and integrated automated deployment of database design.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- XIDIAN UNIV
- Filing Date
- 2025-09-04
- Publication Date
- 2026-04-24
AI Technical Summary
Existing database design tools cannot directly generate ER diagrams and relational models from natural language input. They lack automatic paradigm judgment and constraint reasoning mechanisms, are complex to operate, lack integrated implementation across the entire process, cannot achieve one-click automatic deployment, and are difficult to meet the needs of non-professionals.
Using a large language model-based approach, combined with a pre-set chained reasoning prompt template, natural language requirements are parsed, a database model is generated, and normalization and integrity checks are performed. SQL statements are then automatically generated and deployed to the local database.
It achieves end-to-end automated conversion from natural language requirements to database structure, improving design efficiency and accuracy, lowering the barrier to entry, supporting closed-loop automation throughout the entire process, and enhancing user interaction experience and system maintainability.
Smart Images

Figure CN121144285B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of database design automation and artificial intelligence application technology, specifically relating to a database automatic design method and system based on a large language model. Background Technology
[0002] As information system requirements become increasingly diverse, databases, as core components, undertake the critical tasks of data storage, management, and retrieval. The design quality of a database directly impacts the maintainability, scalability, and performance of the system.
[0003] The database design process includes: requirements analysis → conceptual structure design (building ER diagrams) → logical structure design (converting ER diagrams into relational models) → writing SQL statements → database deployment. This process is typically completed manually by database engineers or system architects. Specifically, this involves manually building ER diagrams based on user requirements, deriving relational schemas, writing SQL statements, and manually deploying them to the database environment. This process not only has a high professional threshold and relies heavily on specialized experience, but it is also cumbersome, has a long development cycle, is inefficient, and prone to problems such as non-standard models and missing constraints, especially when dealing with complex systems (such as e-commerce platforms and management systems).
[0004] In recent years, although auxiliary modeling tools such as PowerDesigner, ER / Studio, and Navicat have emerged in the market, offering functions such as ER diagram drawing, physical modeling, and script generation, they still require users to have a certain level of database modeling expertise. These tools themselves cannot understand user business needs and remain at a "semi-automated" level. On the other hand, with the development of Natural Language Processing (NLP) and Large Language Modeling (LLM) technologies, it has become possible to use AI to understand user language and automatically deduce structures and rules, gradually expanding the boundaries of automated database design.
[0005] However, existing tools generally have the following shortcomings when supporting database-aided design:
[0006] 1. Natural language cannot be directly converted into structural design: Current tools cannot directly generate ER diagrams and relational models based on natural language input, requiring users to understand the requirements and manually model them.
[0007] 2. Lack of automatic paradigm judgment and constraint reasoning mechanism: Existing systems usually only provide structure editing functions, lack the ability to identify functional dependencies and paradigm standards, and have difficulty automatically generating integrity rules such as uniqueness, foreign keys, and check constraints.
[0008] 3. Lack of end-to-end integrated implementation capability: Multiple stages in the design process are completed in different tools, lacking unified system integration. For example, relational models need to be imported into SQL tools for deployment, and normalization checks rely on external scripts, which is inefficient and prone to errors.
[0009] 4. Complex operation and lack of interactive guidance: Most tools are geared towards professionals and lack user-friendly support for beginners or non-database professionals, and lack clear guidance and streamlined operation.
[0010] 5. Unable to achieve “one-click” automatic deployment: During the database deployment phase, most tools only support generating SQL scripts and do not support automatically executing them to the local database, lacking closed-loop design support. Summary of the Invention
[0011] To address the aforementioned problems in the existing technology, this invention provides a database automatic design method, system, electronic device, and storage medium based on a large language model. The technical problem to be solved by this invention is achieved through the following technical solution:
[0012] In a first aspect, embodiments of the present invention provide an automatic database design method based on a large language model, the method comprising:
[0013] Based on a large language model that combines pre-set chain-reasoning prompts and engineering templates, the natural language requirements information for the database input by the user is parsed and processed to obtain a preliminary database model, including database design elements and ER diagrams.
[0014] Perform normalization and integrity checks on the initially constructed database model;
[0015] After the inspection is passed, the initially constructed database model is converted into SQL statements and deployed by connecting it to the local MySQL database.
[0016] In one embodiment of the present invention, the design of the preset chain-based reasoning prompt engineering template combination follows the principles of stage guidance, structured output, semantic understanding guidance, and adaptability; the preset chain-based reasoning prompt engineering template combination is represented as follows: It includes a 13-stage project template, with stages 1 to 6 covering the entire process from entity identification to conceptual model construction; and stages 7 to 13 covering the entire process from logical model construction, paradigm optimization, and structure file generation.
[0017] In one embodiment of the present invention, the preset chain-based reasoning prompt engineering template combination includes:
[0018] Project template prompt This is used to extract entities from the natural language requirement information in the database design and output an entity list in the form of one entity per line; where an entity is the core unit representing a business object in the database.
[0019] Project template prompt This is used to supplement attributes for each extracted entity. Each attribute includes a field name, data type, whether it is a primary key, and constraints. The attributes corresponding to the entity are output in tabular form. The constraints include not null and unique.
[0020] Project template prompt This tool is used to analyze the possible relationships between entities, determine the type of relationship, and describe them in natural language. It outputs the entity relationships and relationship types in the form of a list. The relationship types include one-to-one, one-to-many, and many-to-many.
[0021] Project template prompt It is used to integrate and generate a clear conceptual model structure description based on the extracted entities, attributes and relationships, including entities, attributes, relationships and relationship types, and output them in the form of a structured text table of conceptual model description;
[0022] Project template prompt This is used to modify the entity, attribute, and relationship information in the given Python example code structure to generate Python code for drawing conceptual ER diagrams, so that Graphviz or other graphics libraries can be used to draw conceptual ER diagrams;
[0023] Project template prompt This is used to create a mediation table for all many-to-many relationships. If the relationship has attributes, they are also included in the mediation table. The new entity information is organized to transform special relationships into mediation entities, and a list of mediation entities and instructions on how to split them are output.
[0024] Project template prompt This is used to relist all the disassembled connections, clearly label them, and represent all connections in a structured table format;
[0025] Project template prompt Used to integrate entity and contact information after introducing intermediary entities, and output the logical model design content in the form of a logical model structured description table, including entity fields, contact and attribute descriptions;
[0026] Project template prompt Using the reference logical model and the provided code template, output the Python code for the logical ER diagram to draw the logical ER diagram, reflecting the intermediary entities and the direction of relationships;
[0027] Project template prompt This is used to generate a relational model that conforms to the first normal form based on the logical model information. Each table has one row, listing multiple information including table name, fields, primary and foreign keys, and is saved as a standard txt text file, where each row represents a relational table structure.
[0028] Project template prompt This is used to extract functional dependencies from each relation and output the functional dependency relations in a standard txt text format, with one section for each relation.
[0029] Project template prompt Used to generate constraints for each table based on attributes and relationship information and save them as a constraint list in TXT text format;
[0030] Project template prompt This tool is used to generate foreign key constraints based on the needs of each entity, thereby generating integrity constraint check information and targets. The final output is a list of foreign key information in txt text format.
[0031] In one embodiment of the present invention, the database design elements include entities, attributes, relationships, constraints, primary keys, foreign keys, intermediary entities and their attributes, and functional dependencies; the ER diagram includes a conceptual ER diagram and a logical ER diagram.
[0032] In one embodiment of the present invention, the large language model includes the DeepSeek large language model.
[0033] In one embodiment of the present invention, the initially constructed database model is subjected to normalization and integrity checks, including performing the following steps for each entity corresponding to each table:
[0034] Relation schema parsing steps: Read the structured entity relation definition file in the initially constructed database model, identify and extract the attribute set and primary key and foreign key identifiers of the current table through regular expressions, and construct a table structure dictionary;
[0035] Function dependency resolution steps: Read the function dependency file in the initially constructed database model; the function dependency file records the dependency relationships between attributes in each table, and the system reads these rules one by one and organizes and classifies them for subsequent use;
[0036] The steps for calculating the attribute closure are as follows: Given a set of attributes currently being traversed and all functional dependencies of the current table, first use the attribute set itself as the starting point, making the initial closure include all attributes of the attribute set; continuously check the functional dependencies; if the preconditions of a dependency are already included in the closure, but the result it determines is not yet in the closure, then add this result to the closure; repeat the above process until the closure no longer changes; so that the final closure contains all fields that can be derived from the original attribute set, thus achieving attribute expansion;
[0037] Superkey determination steps: For each attribute set, calculate the closure of the attribute set; check if the closure contains all fields of the current table; if it does, the attribute set is considered a superkey, sufficient to uniquely identify each row in the table; finally, obtain the superkey determination result for each attribute set.
[0038] The normal form determination steps are as follows: First Normal Form (1NF), Second Normal Form (2NF), Third Normal Form (3NF), and BCNF. Specifically, the 1NF step checks if all attributes are atomic values. The 2NF step, for a composite primary key, checks if there exists a proper subset of attributes that depend on the primary key, and if such dependent attributes are non-prime attributes; if such dependencies exist, 2NF is not satisfied. The 3NF step checks if there exists a non-prime attribute that transitively depends on the primary key; if so, 3NF is not satisfied. The BCNF step checks if the left-hand side attribute of each functional dependency is a superkey; if a non-superkey functional dependency exists on the left-hand side, BCNF is not satisfied.
[0039] The integrity constraint check steps include a primary key integrity check step and a foreign key integrity check step; wherein, the primary key integrity check step is to confirm that each table defines a primary key and that the primary key attribute does indeed exist in the table structure; the foreign key integrity check step is to verify whether all foreign key information meets the conditions through the foreign key constraint text;
[0040] Results feedback steps: Output the normalization level of each table, including 1NF, 2NF, 3NF, BCNF and the specific violated functional dependencies, output the integrity constraint check results, and indicate whether the primary key and foreign key are correct.
[0041] In one embodiment of the present invention, after the check passes, the initially constructed database model is converted into SQL statements and deployed by connecting to a local MySQL database, including:
[0042] By using predefined detailed mapping specifications, the corresponding SQL table structure is automatically generated by parsing the entities and attributes in the logical model, and appropriate data types are defined for each attribute, and primary keys and foreign keys are defined for each table;
[0043] Using the built-in integrity constraint generation mechanism, based on multiple conditions determined in the design phase, including primary keys, foreign keys, uniqueness constraints, and check constraints, these constraints are automatically embedded into the generated SQL statement.
[0044] The generated SQL statements are executed in the local MySQL database. The database connection is managed using the Datagrip interface, and the creation and constraints of the database tables are verified to ensure that the generated database tables are consistent with the design. Finally, the deployment results are output.
[0045] Secondly, embodiments of the present invention provide an automatic database design system based on a large language model, the system comprising:
[0046] The natural language parsing module is used to parse and process the natural language requirements information for the database input by the user based on a large language model combined with a preset chain reasoning prompt engineering template, so as to obtain a preliminary database model, including database design elements and ER diagrams.
[0047] The normalization and integrity checking module is used to perform normalization and integrity checks on the initially constructed database model;
[0048] The SQL auto-generation and local deployment module is used to convert the initially constructed database model into SQL statements after the check is passed, and then connect to the local MySQL database for deployment.
[0049] Thirdly, embodiments of the present invention provide an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0050] The memory is used to store computer programs;
[0051] When the processor executes the program stored in the memory, it implements the steps of the database automatic design method based on a large language model provided in the embodiments of the present invention.
[0052] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the database automatic design method based on a large language model provided in embodiments of the present invention.
[0053] The database automatic design method based on a large language model provided in this embodiment of the invention firstly parses and processes the natural language requirement information for the database input by the user based on a large language model combined with a preset chain-reasoning prompt engineering template, to obtain a preliminary database model, including database design elements and ER diagrams; secondly, the preliminary database model is subjected to normalization and integrity checks; and then, after the checks pass, the preliminary database model is converted into SQL statements and deployed by connecting it to a local MySQL database.
[0054] This invention, by constructing an automated database design system based on a large language model, achieves end-to-end automated transformation from natural language requirements to database structure design, bringing the following significant benefits:
[0055] 1. Improve design efficiency: The system adopts an interactive mode that combines step-by-step questioning with real-time generation. Combined with the embedded chain prompt engineering, it automatically completes complex entity recognition, attribute supplementation, relationship analysis and paradigm judgment, which greatly reduces the time and workload of manual modeling.
[0056] 2. Enhance design accuracy and standardization: Utilize the powerful natural language understanding capabilities of large language models to accurately extract core information from database design. Combine this with automatic normalization checks and integrity constraint generation to ensure that design results meet database standards and specifications, thereby improving model quality and maintainability.
[0057] 3. Achieve modularity and decoupling, facilitating expansion and maintenance: Decoupling between modules is achieved through intermediate files and memory structures, ensuring that each module runs independently and stably, and facilitating subsequent functional expansion, maintenance, and upgrades.
[0058] 4. Supports full-process closed-loop automation: From requirement input, structure extraction, ER diagram generation to normalization judgment and SQL script deployment, a complete automated process closed loop is formed, realizing seamless conversion from natural language to database system, which is suitable for teaching, rapid prototyping and low-code platforms.
[0059] 5. Enhance user interaction and visualization: Through a user-friendly graphical interface and automatically generated ER diagrams, users can intuitively understand the database structure, modify and iterate designs in real time, lower the barrier to entry, and improve user satisfaction.
[0060] In summary, this invention not only improves the intelligence and automation level of database design, but also enhances the system's practicality and engineering adaptability, promoting the transformation of database design from traditional manual methods to intelligent assistance. Attached Figure Description
[0061] Figure 1This is a flowchart illustrating an automatic database design method based on a large language model, provided in an embodiment of the present invention.
[0062] Figure 2 The image shows a comparison of natural language extraction results for a large model. The left side represents the project without prompts, and the right side represents the project with prompts.
[0063] Figure 3 This provides a conceptual model for an engineering example of an embodiment of the present invention.
[0064] Figure 4 This is an example of a logic model generation prompt project for an embodiment of the present invention;
[0065] Figure 5 ER diagrams generated for simple graphical description instructions;
[0066] Figure 6 The ER diagram generated by the systematic example code suggestion template of this invention embodiment;
[0067] Figure 7 This is a sample diagram of natural language input in an embodiment of the present invention;
[0068] Figure 8 This is an ER diagram of the conceptual model of the parts trading center management system according to an embodiment of the present invention;
[0069] Figure 9 This is an ER diagram of the logical model of the parts trading center management system according to an embodiment of the present invention;
[0070] Figure 10 This is an example of a parts trading center management system database in an embodiment of the present invention;
[0071] Figure 11 This is a schematic diagram of the structure of an automatic database design system based on a large language model provided in an embodiment of the present invention;
[0072] Figure 12 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0073] The present invention will be further described in detail below with reference to specific embodiments, but the implementation of the present invention is not limited thereto.
[0074] Firstly, embodiments of the present invention provide an automated database design method based on a large language model. This method is an end-to-end automated conversion method from natural language requirements to database structure design, and it constructs a database automated design system framework based on a large language model. This method comprehensively utilizes multiple stages such as large model hinting engineering, structure extraction, graphical interface interaction, normalization judgment, and SQL deployment to achieve automatic parsing and structured design of natural language database requirements, forming a closed-loop database design process. The method as a whole follows a closed-loop process of "perception—understanding—modeling—implementation." Figure 1 As shown, the method may include the following steps:
[0075] S1, based on a large language model that combines preset chain-based reasoning prompts and engineering templates, parses and processes the natural language requirements information for the database input by the user to obtain a preliminary database model, including database design elements and ER diagrams.
[0076] In this embodiment of the invention, the preset chained reasoning prompt engineering template combination is a structured and scalable multi-step chained reasoning prompt template that can automatically provide explicit guidance to the model at each stage, enabling the large language model to gradually extract complete information such as entities, attributes, relationships, constraints, and functional dependencies from natural language requirement information. The large language model includes DeepSeek large language models, etc.
[0077] Specifically, the database design elements include entities, attributes, relationships, constraints, primary keys, foreign keys, mediator entities and their attributes, and functional dependencies; the ER diagram includes conceptual ER diagrams and logical ER diagrams.
[0078] In this embodiment of the invention, the design of the preset chain-based reasoning prompt engineering template combination follows the principles of stage guidance, structured output, semantic understanding guidance, and adaptability, specifically manifested in:
[0079] (1) Phase guidance principle: Each prompt engineering template is designed around the current sub-task goal, guiding the model to reason step by step and avoiding information omission or confusion.
[0080] (2) Structured output principle: The prompts in the project templates at each stage encourage the output of structured content in JSON or table format to facilitate subsequent code processing and database construction.
[0081] (3) Semantic understanding-oriented principle: The design of the engineering template emphasizes "semantic drive" to avoid the model only matching keywords, but to understand the logic behind the user's business needs.
[0082] (4) Adaptability principle: The prompt engineering template supports dynamic replacement of keywords such as entities and business content to adapt to input scenarios in different fields.
[0083] In this embodiment of the invention, the preset chain-based reasoning prompt engineering template combination is represented as follows: This set of prompt engineering templates includes 13 stages. Stages 1 to 6 cover the entire process from entity identification to conceptual model construction; stages 7 to 13 cover the entire process from logical model construction, paradigm optimization, and structure file generation. This pre-set chain-reasoning prompt engineering template set not only clearly defines the tasks in stages, but also ensures that the output of each step can be connected to the next step, forming a closed-loop path from requirements to structural modeling.
[0084] Specifically, in the preset chain-based reasoning prompt engineering template combination:
[0085] 1) Project template prompt This is used to extract entities from the natural language requirement information in the database design and output an entity list in the form of one entity per line; where an entity is the core unit representing a business object in the database; the entity list can be plain text or a JSON array;
[0086] 2) Project template prompt This is used to supplement attributes for each extracted entity. Each attribute includes a field name, data type, whether it is a primary key (PK), and constraints. The attributes corresponding to the entity are output in tabular form. Data types can include strings, integers, floating-point numbers, dates, times, etc. Constraints include NOT NULL and unique. A primary key is a column or combination of columns used to uniquely identify each record in a database table. A foreign key (FK) is a column or combination of columns used to establish and strengthen the link between data in two tables; please refer to the relevant technical explanations for details. It is understood that the output table needs to include fields + data type + primary key / foreign key + constraints.
[0087] 3) Project template prompt This tool is used to analyze the possible relationships between entities, determine their relationship types, and describe them in natural language. It outputs the entity relationships and relationship types in the form of a list. The relationship types include one-to-one, one-to-many, and many-to-many.
[0088] 4) Project template prompt It is used to integrate and generate a clear conceptual model structure description based on the extracted entities, attributes and relationships, including entities, attributes, relationships and relationship types, and output them in the form of a structured text table of conceptual model description;
[0089] 5) Project template prompt This is used to modify the entity, attribute, and relationship information in the given Python example code structure to generate Python code for drawing conceptual ER diagrams, so that Graphviz or other graphics libraries can be used to draw conceptual ER diagrams;
[0090] 6) Project template prompt This tool is used to create a mediation table for all many-to-many relationships (i.e., N:M relationships). If the relationship has attributes, these attributes are also included in the mediation table. The tool organizes new entity information to transform special relationships into mediation entities and outputs a list of mediation entities and instructions on how to split them.
[0091] 7) Project template prompt This is used to relist all the disassembled connections, clearly label them, and represent all connections in a structured table format;
[0092] 8) Project template prompt Used to integrate entity and contact information after introducing intermediary entities, and output the logical model design content in the form of a logical model structured description table, including entity fields, contact and attribute descriptions;
[0093] 9) Project template prompt Using the reference logical model and the provided code template, output the Python code for the logical ER diagram to draw the logical ER diagram, reflecting the intermediary entities and the direction of relationships;
[0094] 10) Project template prompt This is used to generate a relational model that conforms to the first normal form based on the logical model information. Each table has one row, listing multiple information including table name, fields, primary and foreign keys, and is saved as a standard txt text file, where each row represents a relational table structure.
[0095] 11) Project template prompt This is used to extract functional dependencies from each relation and output the functional dependency relations in a standard txt text format, with one section for each relation.
[0096] 12) Project template prompt Used to generate constraints for each table based on attributes and relationship information and save them as a constraint list in TXT text format;
[0097] 13) Project template prompt This tool is used to generate foreign key constraints based on the needs of each entity, thereby generating integrity constraint check information and targets. The final output is a list of foreign key information in txt text format.
[0098] Please refer to Table 1 for the specific templates for each of the above-mentioned prompts.
[0099] Table 1. Hint Project + Mind Chain Template (From Entity Extraction to Conceptual Model)
[0100]
[0101] Table 2. Hint Project + Mind Chain Template (From Logical Model to Relational / Constraint Output)
[0102]
[0103] The pre-defined chain-reasoning prompt engineering template combination of this invention emphasizes the transition from modeling structure to program-processable structure. By using a txt file as an intermediate layer, it effectively decouples the model from the engineering logic, making it more scalable and stable.
[0104] Step S1 can utilize large language models (LLM) such as DeepSeek combined with chain-of-thought reasoning strategies to gain a deeper understanding of semantically complex and ambiguous input scenarios. Through a preset 13-step prompt engineering template, it can achieve phased, multi-round automatic reasoning and structured extraction, automatically transforming the user's natural language input requirements into structured database model elements, providing basic support for subsequent ER diagram generation, relational model design, and database deployment.
[0105] The pre-defined chain-based reasoning prompting template combination first relies on DeepSeek's powerful contextual understanding capabilities to accurately identify entities described in natural language (such as "student," "order," and "doctor") and the attribute information contained in these entities (such as "name," "order time," and "department"). It also understands implicit relationships in the language, such as synonyms, pronouns, ellipsis, and contextual logic. For example, in the sentence "Each doctor belongs to a department," it not only identifies "doctor" and "department" as two entities but also infers their hierarchical relationship. Then, a chain-based thinking strategy is employed for refinement, using multi-round prompting engineering to achieve progressive reasoning. This significantly improves the model's ability to identify complex business structures, and is particularly suitable for parsing nested structures, implicit constraints, and multi-entity cross-relationships.
[0106] To visually demonstrate the advantages of the prompting engineering template of this invention in the natural language parsing process, a requirement description of a "library management system" is selected as the input example. The extraction performance of traditional keyword matching methods and the chain-reasoning prompting engineering method of this invention are compared. Traditional methods mainly rely on surface-level word matching and extraction, making it difficult to capture the complex semantic relationships between entities. Furthermore, their ability to identify intermediary entities and their business attributes is limited, resulting in a lack of systematicity and completeness in the extraction results. In contrast, the chain-reasoning prompting engineering template used in this invention guides the model to gradually identify subjects, attributes, and the multi-level relationships between them, effectively improving the accuracy and logical coherence of structured information. Figure 2 The comparison results of the two methods are shown. The left side shows the extraction results without prompting engineering, and the right side shows the results based on prompting engineering, which clearly demonstrates the advantages of the present invention in natural language parsing.
[0107] With the above-mentioned prompt engineering template, you only need to input the database design requirements described in natural language (i.e., natural language requirement information), and the database design elements, including entities, attributes, relationships, constraints, primary keys, foreign keys, mediator entities and their attributes, functional dependencies, etc., can be automatically extracted through multiple rounds of interaction and prompt chain guidance, which greatly improves the efficiency and accuracy of database design.
[0108] It is worth mentioning that this invention provides a method for visualizing ER diagrams (see [link]). and Unlike traditional ER diagram construction methods that are developed independently in stages, this invention further derives a logical model structure based on the conceptual model generation, constructing an end-to-end automated modeling closed loop from natural language requirements to database structure. This innovative architecture not only significantly improves the accuracy of semantic expression and model integrity, but also greatly enhances the level of intelligence and automation. In addition, the method provided by this invention does not run as an independent script or function, but is embedded in the prompting project of the large language model. After receiving the structured entity and relation descriptions, the model directly outputs Python code that conforms to the ER modeling specifications based on a carefully designed prompt template. A clear ER diagram is generated through the Python environment, in which primary keys, foreign keys, attributes, and the relationship types between entities (such as one-to-one, one-to-many, and many-to-many) are clearly marked.
[0109] The method provided by this invention highly relies on rigorous design of the prompting engineering. This is achieved through prompt templates designed separately for the conceptual model and the logical model (see...). Figure 3 The conceptual model shown prompts engineering examples and Figure 4 The example of generating logical model prompts effectively guides the model to output Python graphical description code that conforms to specifications and has accurate semantics, greatly improving the success rate and quality of automatic conversion from natural language to ER diagrams.
[0110] To further explore the role of suggestion engineering in natural language parsing and ER graph generation, we introduce... Figure 5 and Figure 6 The comparison demonstrates the significant differences in the model output effects of the two prompting strategies. Figure 5 The image shows the result generated based on simple instructions (such as "draw an ER diagram"). This strategy lacks standardized conventions for the representation of entities, attributes, and relationships, resulting in a chaotic graphical structure, unclear direction, and semantic ambiguity in the generated model. This severely impacts the visualization quality and its application value in database design. In contrast, Figure 6 This paper demonstrates the generated results after adopting a systematic example code suggestion template. This template effectively guides the model to complete chain-like reasoning and structured output by clearly suggesting the steps of entity recognition, attribute attribution, and relationship modeling, thereby generating a clear, semantically accurate, and highly practical ER diagram. Therefore, it is evident that a systematic and structured suggestion strategy significantly improves the performance of large language models in automatic database modeling tasks.
[0111] After step S1, the user's natural language requirement information is progressively parsed by the large language model into entities, attributes, relationships, constraints, primary keys, foreign keys, intermediary entities and their attributes, and functional dependencies based on chained prompts, and then the relational model of the database is automatically constructed. Taking the "Parts Trading Center Management System" as an example, such as... Figure 7 As shown, the natural language demand information on the left will be gradually and successfully identified to identify entities such as suppliers, customers, and parts, along with their detailed attributes, and the business relationships between these entities will be extracted to form structured information.
[0112] After the user enters natural language use cases (i.e., natural language requirements) on the left side of the interface and clicks "Start," they will interact with all the suggested engineering templates. The system uses built-in prompts to progressively elicit questions from the large language model. Simultaneously, the user can select a model in the upper left corner to build the database system. By progressively parsing the natural language and prompting the large language model, structured entity information can be obtained. The system also automatically generates the following key intermediate files.
[0113] model.txt: Records the description of the relational model;
[0114] functional_dependencies.txt: Records functional dependencies;
[0115] constraints.txt: Records integrity constraints (such as NOT NULL, check constraints, default values, etc.).
[0116] foreign_keys.txt: Records all foreign key relationships in the database system for integrity checks.
[0117] In addition, corresponding conceptual and logical model ER diagram code is generated and visualized. Figure 8 The conceptual model ER diagram for the "Parts Trading Center Management System" retains the original business semantic structure, especially the natural description of many-to-many relationships. Diamonds are used to represent the connections between entities, which is beneficial for subsequent structural analysis and optimization of the model. Figure 9 The logical model ER diagram of the "Parts Trading Center Management System" was used to transform the conceptual model. Based on the rules, it was determined whether to split the relationship and introduce the intermediary entity. This process is closer to the table structure of the actual database and helps with SQL table creation and relation normalization (i.e., normalization judgment).
[0118] As can be seen, step S1 achieves the initial construction of the database model.
[0119] This invention provides a natural language parsing technology based on large language models. It employs a large language model (such as DeepSeek) combined with chained suggestion engineering to achieve multi-turn, step-by-step parsing of complex natural language requirements. It automatically extracts entities, attributes, functional dependencies, and primary / foreign key relationships from database designs, significantly improving parsing accuracy and automation. Simultaneously, it achieves conceptual-logical dual-layer modeling and visualization support. Specifically, this invention proposes a dual-perspective modeling method combining a conceptual model (user-oriented ER diagram) and a logical model (system-oriented relational model), enhancing the semantic expressiveness of the database structure while improving the system's visualization and interpretability. Furthermore, the automatically generated ER diagram visualization intuitively displays entities, attributes, and their relationship types (1:1, 1:N, M:N). This visualization helps developers and business personnel quickly understand the data model structure, greatly improving design efficiency and communication effectiveness.
[0120] S2, Perform normalization and integrity checks on the initially constructed database model;
[0121] Step S2 is designed to introduce a database normalization judgment mechanism to ensure that the database model in the logical modeling phase conforms to the specifications and has good scalability. Unlike traditional database design methods, step S2, by dynamically performing normalization and integrity checks during the modeling process, not only achieves a comprehensive review of the data structure but also provides real-time optimization feedback during the design process, greatly improving modeling efficiency and data model quality.
[0122] Specifically, in S2, the initially constructed database model undergoes normalization and integrity checks, including performing the following steps for each entity corresponding to each table:
[0123] S21, Relationship schema parsing steps: Read the structured entity relationship definition file in the initially constructed database model, identify and extract the attribute set and primary key and foreign key identifiers of the current table through regular expressions, and construct a table structure dictionary. The attribute set is used for the determination of superkeys in S24, and the primary and foreign key identifiers are used for the integrity check of primary and foreign keys in S26.
[0124] S22, Function dependency resolution step: Read the function dependency file in the initially constructed database model; the function dependency file records the dependency relationships between attributes in each table, and the system reads these rules one by one and organizes and classifies them for subsequent use;
[0125] The function dependency file records the dependencies between attributes in each table. For example, if a student's student ID can uniquely determine their name, then "student ID -> name" is identified as a function dependency.
[0126] S23, Attribute Closure Calculation Steps: Given a currently traversed attribute set (e.g., {A, B}) and all functional dependencies (i.e., the determination relationships between fields) of the current table, first take this attribute set itself as the starting point, making the initial closure include all attributes of this attribute set; continuously check functional dependencies; if the preconditions of a dependency (i.e., the fields on the left) are already included in the closure, but the result it determines (i.e., the fields on the right) is not yet in the closure, then add this result to the closure; repeat the above process until the closure no longer changes; so that the final closure contains all fields that can be derived from the original attribute set, thus achieving attribute expansion;
[0127] S24, Superkey determination steps: For each attribute set, calculate the closure of the attribute set; check whether the closure contains all fields of the current table; if it does, the attribute set is considered a superkey, sufficient to uniquely identify each row in the table; finally, obtain the superkey determination result for each attribute set.
[0128] S25, Normal form judgment steps: First Normal Form (1NF) judgment steps, Second Normal Form (2NF) judgment steps, Third Normal Form (3NF) judgment steps, and BCNF judgment steps; among which...
[0129] The first normal form (1NF) judgment step is to check whether all properties are atomic values (assuming the input satisfies 1NF);
[0130] The second normal form (2NF) determination steps are as follows: for a composite primary key, determine whether there exists a proper subset of attributes that depend on the primary key, and the dependent attributes are non-primary attributes; if such a partial dependency exists, it is determined that 2NF is not satisfied.
[0131] The 3NF judgment step of the third normal form is to determine whether there is a non-prime attribute transitively dependent on the primary key, that is, dependent on the non-superkey on the left and the non-prime attribute on the right. If it exists, then 3NF is not satisfied.
[0132] The BCNF determination step is to determine whether the left-hand attribute of each functional dependency is a superkey. If there is a functional dependency with a non-superkey left-hand attribute, then BCNF is not satisfied.
[0133] S26, the integrity constraint check steps include primary key integrity check steps and foreign key integrity check steps; wherein...
[0134] The primary key integrity check step is to confirm that each table defines a primary key and that the primary key attribute does indeed exist in the table structure.
[0135] The foreign key integrity check step is to verify whether all foreign key information meets the conditions by using the foreign key constraint text;
[0136] S27, Result Feedback Steps: Output the normalization level of each table, including 1NF, 2NF, 3NF, BCNF, and the specific violated functional dependencies. Output the integrity constraint check results and indicate whether the primary key and foreign key are correct.
[0137] Understandably, for each entity corresponding to a table in the initially constructed database model, S21-S27 are executed until all tables have been traversed and checked.
[0138] The above process of this invention can be implemented with code. This invention combines functional dependency to automatically determine 1NF, 2NF, 3NF and BCNF normal forms, automatically generate primary keys, foreign keys, uniqueness, check constraints, etc., to ensure that the database structure conforms to the standard, reduce human error, and realize automated normal form checking and integrity constraint generation.
[0139] S3. After the check is passed, the initially constructed database model is converted into SQL statements and deployed by connecting it to the local MySQL database.
[0140] Specifically, S3 may include the following steps:
[0141] S31 utilizes predefined detailed mapping specifications to automatically generate corresponding SQL table structures by parsing entities and attributes in the logical model, and defines appropriate data types for each attribute and primary keys and foreign keys for each table;
[0142] After normalization testing, the relational (logical) model is converted into specific SQL statements and deployed to a local MySQL database. To ensure accurate conversion from the logical model to the database table structure, this invention defines detailed mapping specifications. By parsing the entities and relationships in the logical model, it can automatically generate the corresponding SQL table structure, define appropriate data types for each attribute, and define primary keys, foreign keys, etc., for each table.
[0143] S32 utilizes an embedded integrity constraint generation mechanism to automatically embed multiple conditions determined during the design phase, including primary keys, foreign keys, uniqueness constraints, and check constraints, into the generated SQL statement.
[0144] S33 executes the generated SQL statements into the local MySQL database, manages the database connection using the Datagrip interface, verifies the correctness of the database table creation and constraints, ensures that the generated database tables are consistent with the design, and finally outputs the deployment results.
[0145] This invention can implement the functions of the above steps using code. Based on structured database design information obtained from natural language parsing, this invention automatically generates a complete DDL (Data Definition Language) script conforming to MySQL specifications. The generated SQL script not only includes basic table creation statements but also automatically integrates integrity rules such as primary keys, foreign keys, uniqueness, NOT NULL, and constraint checks, ensuring the rigor of the database structure and data consistency. The automatically generated DDL script undergoes rigorous syntax and specification validation and can be directly used in a MySQL environment without manual modification or secondary processing. It can automatically achieve local SQL deployment, greatly improving the efficiency from database design to deployment.
[0146] Figure 10 These are six database tables generated and deployed for the "Parts Trading Center Management System".
[0147] To verify the effectiveness of the method in the embodiments of the present invention, relevant experimental evidence is provided below.
[0148] To systematically evaluate the accuracy of the proposed method in generating database structures driven by natural language, and given the current lack of publicly available benchmark datasets for this purpose, this invention has built its own test set. All samples are taken from authoritative database textbooks and high-level research papers, covering multiple application areas such as e-commerce, healthcare, and student management, ensuring that the test corpus has a certain degree of representativeness and credibility in terms of semantic expression, structural complexity, and modeling standardization.
[0149] Each sample in the test set includes a natural language description, expert-provided standard database modeling results, and automatically generated output from the system. It supports precise performance evaluation across three dimensions: entity recognition (whether it can correctly identify all entities in the text), attribute extraction (whether the extracted attributes for each entity are complete and correct), and relationship judgment (whether it can correctly identify the relationships and types between entities). The sample size comprises 15 groups, categorized into small (2–3 entities), medium (4–7 entities), and large (8–10 entities) systems based on the number of entities, covering various structural scales and expression styles, providing good breadth and depth of evaluation. Then, using manually annotated standard results as a benchmark, the precision and recall of the system output compared to the standard answer in structure extraction are calculated. The complete test set has been compiled and released as open source, available for download on GitHub at the following address.
[0150] https: / / github.com / sunshine0677 / projcet_datasett .
[0151] The evaluation results are summarized in Table 3.
[0152] Table 3 Evaluation Results
[0153]
[0154] Performance Analysis of Small Systems: In small systems, all models exhibit near-perfect accuracy and completeness across the three dimensions of entities, attributes, and relationships. Except for Model 3, which showed a slight decrease in relationship recognition (recall and precision both at 80%), and Model 4, whose attribute precision was slightly lower (93.3%), all other metrics were 100%. This indicates that the decrease in precision and recall is primarily due to the fact that natural language descriptions of conceptual models are not entirely detailed and specific, resulting in some slight deviations, but these do not affect the overall representation of the system. Overall, small systems have relatively simple structures, and the system demonstrates extremely high stability and robustness in processing them.
[0155] Performance Analysis of Medium-Sized Systems: In medium-sized systems, "entity recognition" and "relationship recognition" still perform well, but "attribute extraction" shows a decrease in recall and precision in some models (such as models 6 and 7). This is mainly due to the complexity or ambiguity of attribute descriptions in natural language. However, overall, the system maintains a high recognition accuracy on medium-sized structures and exhibits good robustness.
[0156] Performance Analysis of Large-Scale Systems: As the system scale and structural complexity increase, some models in large-scale systems experience a certain degree of performance decline in entity and relationship recognition. For example, the relationship accuracy of Model 12 drops to 81.8%, and the entity accuracy of Model 15 is only 83.3%. Nevertheless, the attribute extraction dimension still performs well overall, remaining at or near 100%. This indicates that the system still possesses strong modeling capabilities in complex scenarios, but there is still room for optimization in handling certain marginal or semantically ambiguous information.
[0157] Overall performance: The system demonstrates good generalization ability and stability in structural information extraction tasks, making it particularly suitable for domain scenarios with relatively clear structures. Furthermore, the system maintains strong adaptability even with increased complexity.
[0158] The database automatic design method based on a large language model provided in this embodiment of the invention firstly parses and processes the natural language requirement information for the database input by the user based on a large language model combined with a preset chain-reasoning prompt engineering template, to obtain a preliminary database model, including database design elements and ER diagrams; secondly, the preliminary database model is subjected to normalization and integrity checks; and then, after the checks pass, the preliminary database model is converted into SQL statements and deployed by connecting it to a local MySQL database.
[0159] This invention, by constructing an automated database design system based on a large language model, achieves end-to-end automated transformation from natural language requirements to database structure design, bringing the following significant benefits:
[0160] 1. Improve design efficiency: The system adopts an interactive mode that combines step-by-step questioning with real-time generation. Combined with the embedded chain prompt engineering, it automatically completes complex entity recognition, attribute supplementation, relationship analysis and paradigm judgment, which greatly reduces the time and workload of manual modeling.
[0161] 2. Enhance design accuracy and standardization: Leverage the powerful natural language understanding capabilities of large language models to accurately extract core information from database design. Combined with automatic normalization checks and integrity constraint generation, ensure that design results meet database standards and improve model quality and maintainability.
[0162] 3. Achieve modularity and decoupling, facilitating expansion and maintenance: Decoupling between modules is achieved through intermediate files and memory structures, ensuring that each module runs independently and stably, and facilitating subsequent functional expansion, maintenance, and upgrades.
[0163] 4. Supports full-process closed-loop automation: From requirement input, structure extraction, ER diagram generation to normalization judgment and SQL script deployment, a complete automated process closed loop is formed, realizing seamless conversion from natural language to database system, which is suitable for teaching, rapid prototyping and low-code platforms.
[0164] 5. Enhance user interaction and visualization: Through a user-friendly graphical interface and automatically generated ER diagrams, users can intuitively understand the database structure, modify and iterate designs in real time, lower the barrier to entry, and improve user satisfaction.
[0165] In summary, this invention not only improves the intelligence and automation level of database design, but also enhances the system's practicality and engineering adaptability, promoting the transformation of database design from traditional manual methods to intelligent assistance.
[0166] Secondly, corresponding to the above method embodiments, this invention also provides a database automatic design system based on a large language model. This system integrates various functional modules through a graphical user interface (GUI), supporting a one-click design method for the entire process, from requirements analysis to structural modeling, ER diagram visualization, normalization detection, constraint generation, SQL script output, and MySQL deployment. For example... Figure 11 As shown, the system includes:
[0167] The natural language parsing module is used to parse and process the natural language requirements information for the database input by the user based on a large language model combined with a preset chain reasoning prompt engineering template, so as to obtain a preliminary database model, including database design elements and ER diagrams.
[0168] The normalization and integrity checking module is used to perform normalization and integrity checks on the initially constructed database model;
[0169] The SQL auto-generation and local deployment module is used to convert the initially constructed database model into SQL statements after the check is passed, and then connect to the local MySQL database for deployment.
[0170] The three modules mentioned above correspond to S1-S3 respectively. For the specific processing procedures of each module of the system, please refer to the relevant content in the first part, which will not be repeated here.
[0171] The database automatic design system based on a large language model provided in this invention offers an end-to-end automated conversion solution from natural language to structured database design. It employs a complete and closed-loop conversion process, starting from user input of database business requirements in any natural language, automatically completing the entire automated design process from entity extraction, attribute recognition, relationship analysis, normalization detection, logical modeling to final database deployment. This achieves seamless conversion from natural language requirements to database structure design, greatly improving the efficiency and accuracy of database design. Furthermore, this invention provides a multi-round interactive parsing mechanism based on chain-based prompting engineering. The system uses chain-based thinking prompting technology and preset multi-step prompting engineering templates to achieve phased, multi-round parsing of complex business requirements. Each step automatically asks questions and adjusts the parsing results based on user or model feedback, ensuring the accuracy and flexibility of structure extraction, improving parsing effectiveness, and supporting user participation and intervention. Meanwhile, this invention's system can automatically generate ER diagrams. Specifically, it uniquely converts structured database design results into standard Crow's Foot style ER diagrams, using HTML tables to represent the main components and diamond shapes to represent relationships, perfectly visualizing the database. Real-time rendering is achieved using graphical languages such as Graphviz. The system allows users to directly modify the model structure based on the visual diagrams, dynamically synchronizing the underlying code, greatly enhancing the intuitiveness and interactive experience of database conceptual model design. Furthermore, this invention provides automatic normalization judgment and database integrity verification algorithms. The system automatically detects 1NF, 2NF, 3NF, and BCNF normal forms based on extracted functional dependency information, and performs integrity verification by combining entity attributes and constraint information. This algorithm can accurately identify design defects and automatically output normalization reports and problem prompts, significantly improving database design quality and compliance, and reducing the workload of manual checks. Additionally, this invention combines a process for automatically generating and deploying constrained SQL scripts with text configuration files. The system innovatively transforms structural information, constraints, and foreign key information in the logical model into standardized text configuration files as input for automatic SQL script generation. The system-generated DDL statements cover a variety of constraints, including complete primary and foreign keys, uniqueness, NOT NULL, and checks, and support automatic connection and deployment to a local MySQL database via a program interface. This process achieves an automated closed loop from design to deployment, ensuring accurate implementation and efficient delivery of the database structure.
[0172] Thirdly, embodiments of the present invention also provide an electronic device, such as... Figure 12 As shown, it includes a processor 1201, a communication interface 1202, a memory 1203, and a communication bus 1204, wherein the processor 1201, the communication interface 1202, and the memory 1203 communicate with each other through the communication bus 1204.
[0173] The memory is used to store computer programs;
[0174] When the processor executes the program stored in the memory, it implements the steps of any of the database automatic design methods based on a large language model provided in the first aspect of the present invention.
[0175] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0176] The communication interface is used for communication between the aforementioned electronic devices and other devices.
[0177] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0178] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0179] The method provided in this invention can be applied to electronic devices. Specifically, the electronic device can be a desktop computer, a portable computer, a smart mobile terminal, a server, etc. No limitation is made herein; any electronic device that can implement this invention falls within the protection scope of this invention.
[0180] Fourthly, corresponding to the database automatic design method based on a large language model provided in the first aspect, this embodiment of the invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the database automatic design methods based on a large language model provided in the first aspect of this invention.
[0181] For system / electronic device / storage medium embodiments, since they are basically similar to method embodiments, the description is relatively simple, and relevant parts can be found in the description of the method embodiments.
[0182] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. In addition, those skilled in the art can combine and integrate the different embodiments or examples described in this specification.
[0183] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. A database automatic design method based on a large language model, characterized in that, include: Based on a large language model that combines pre-set chain-reasoning prompts and engineering templates, the natural language requirements information for the database input by the user is parsed and processed to obtain a preliminary database model, including database design elements and ER diagrams. Perform normalization and integrity checks on the initially constructed database model; After the inspection is passed, the initially constructed database model is converted into SQL statements and deployed by connecting it to the local MySQL database. The preset chain-based reasoning prompt engineering template combination is represented as follows: It includes a 13-stage project template, among which: Project template prompt This is used to extract entities from the natural language requirement information in the database design and output an entity list in the form of one entity per line; where an entity is the core unit representing a business object in the database. Project template prompt This is used to supplement attributes for each extracted entity. Each attribute includes a field name, data type, whether it is a primary key, and constraints. The attributes corresponding to the entity are output in tabular form. The constraints include not null and unique. Project template prompt This tool is used to analyze the possible relationships between entities, determine their relationship types, and describe them in natural language. It outputs the entity relationships and relationship types in the form of a list. The relationship types include one-to-one, one-to-many, and many-to-many. Project template prompt It is used to integrate and generate a clear conceptual model structure description based on the extracted entities, attributes and relationships, including entities, attributes, relationships and relationship types, and output them in the form of a structured text table of conceptual model description; Project template prompt This is used to modify the entity, attribute, and relationship information in the given Python example code structure to generate Python code for drawing conceptual ER diagrams, so that Graphviz or other graphics libraries can be used to draw conceptual ER diagrams; Project template prompt This is used to create a mediation table for all many-to-many relationship types. If the relationship has attributes, they are also included in the mediation table. The new entity information is organized to transform special relationships into mediation entities, and a list of mediation entities and instructions on how to split them are output. Project template prompt Used to relist all the disassembled connections, clearly labeled, and represent all connections in a structured table format; Project template prompt Used to integrate entity and contact information after introducing intermediary entities, and output the logical model design content in the form of a logical model structured description table, including entity fields, contact and attribute descriptions; Project template prompt Using the reference logical model and the provided code template, output the Python code for the logical ER diagram to draw the logical ER diagram, reflecting the intermediary entities and the direction of relationships; Project template prompt This is used to generate a relational model that conforms to the first normal form based on the logical model information. Each table has one row, listing multiple information including table name, fields, primary and foreign keys, and is saved as a standard txt text file, where each row represents a relational table structure. Project template prompt This is used to extract functional dependencies from each relation and output the functional dependency relations in a standard txt text format, with one section for each relation. Project template prompt Used to generate constraints for each table based on attributes and relationship information and save them as a constraint list in TXT text format; Project template prompt This tool is used to generate foreign key constraints based on the needs of each entity, thereby generating integrity constraint check information and targets. The final output is a list of foreign key information in txt text format.
2. The method according to claim 1, characterized in that, The design of the preset chain-based reasoning prompt engineering template combination follows the principles of stage guidance, structured output, semantic understanding guidance, and adaptability. In the preset chain-based reasoning prompt engineering template combination, stages 1 to 6 cover the entire process from entity recognition to concept model construction; stages 7 to 13 cover the entire process from logical model construction, paradigm optimization, and structure file generation.
3. The method according to claim 1, characterized in that, The database design elements include entities, attributes, relationships, constraints, primary keys, foreign keys, mediator entities and their attributes, and functional dependencies; The ER diagram includes conceptual ER diagrams and logical ER diagrams.
4. The method according to claim 1, characterized in that, The large language model mentioned includes the DeepSeek large language model.
5. The method according to claim 3, characterized in that, Perform normalization and integrity checks on the initially constructed database model, including the following steps for each entity corresponding to each table: Relation schema parsing steps: Read the structured entity relation definition file in the initially constructed database model, identify and extract the attribute set and primary key and foreign key identifiers of the current table through regular expressions, and construct a table structure dictionary; Function dependency resolution steps: Read the function dependency files in the initially constructed database model; The function dependency file records the dependency relationships between attributes in each table. The system reads these rules one by one and organizes and categorizes them for later use. The steps for calculating the attribute closure are as follows: Given a set of attributes currently being traversed and all functional dependencies of the current table, first use the attribute set itself as the starting point, making the initial closure include all attributes of the attribute set; continuously check the functional dependencies; if the preconditions of a dependency are already included in the closure, but the result it determines is not yet in the closure, then add this result to the closure; repeat the above process until the closure no longer changes; so that the final closure contains all fields that can be derived from the original attribute set, thus achieving attribute expansion; Superkey determination steps: For each attribute set, calculate the closure of the attribute set; check if the closure contains all fields of the current table; if it does, the attribute set is considered a superkey, sufficient to uniquely identify each row in the table; finally, obtain the superkey determination result for each attribute set. The normal form determination steps are as follows: First Normal Form (1NF), Second Normal Form (2NF), Third Normal Form (3NF), and BCNF. Specifically, the 1NF step checks if all attributes are atomic values. The 2NF step, for a composite primary key, checks if there exists a proper subset of attributes that depend on the primary key, and if such dependent attributes are non-prime attributes; if such dependencies exist, 2NF is not satisfied. The 3NF step checks if there exists a non-prime attribute that transitively depends on the primary key; if so, 3NF is not satisfied. The BCNF step checks if the left-hand side attribute of each functional dependency is a superkey; if a non-superkey functional dependency exists on the left-hand side, BCNF is not satisfied. The integrity constraint check steps include a primary key integrity check step and a foreign key integrity check step; wherein, the primary key integrity check step is to confirm that each table defines a primary key and that the primary key attribute does indeed exist in the table structure; the foreign key integrity check step is to verify whether all foreign key information meets the conditions through the foreign key constraint text; Results feedback steps: Output the normalization level of each table, including 1NF, 2NF, 3NF, BCNF and the specific violated functional dependencies, output the integrity constraint check results, and indicate whether the primary key and foreign key are correct.
6. The method according to claim 5, characterized in that, After the inspection is passed, the initially constructed database model is converted into SQL statements and deployed to the local MySQL database, including: By using predefined detailed mapping specifications, the corresponding SQL table structure is automatically generated by parsing the entities and attributes in the logical model, and appropriate data types are defined for each attribute, and primary keys and foreign keys are defined for each table; Using the built-in integrity constraint generation mechanism, based on multiple conditions determined in the design phase, including primary keys, foreign keys, uniqueness constraints, and check constraints, these constraints are automatically embedded into the generated SQL statement. The generated SQL statements are executed in the local MySQL database. The database connection is managed using the Datagrip interface, and the creation and constraints of the database tables are verified to ensure that the generated database tables are consistent with the design. Finally, the deployment results are output.
7. A database automatic design system based on a large language model, characterized in that, include: The natural language parsing module is used to parse and process the natural language requirements information for the database input by the user based on a large language model combined with a preset chain reasoning prompt engineering template, so as to obtain a preliminary database model, including database design elements and ER diagrams. The normalization and integrity checking module is used to perform normalization and integrity checks on the initially constructed database model; The SQL auto-generation and local deployment module is used to convert the initially constructed database model into SQL statements and deploy it to the local MySQL database after the check is passed. The preset chain-based reasoning prompt engineering template combination is represented as follows: It includes a 13-stage project template, among which: Project template prompt This is used to extract entities from the natural language requirement information in the database design and output an entity list in the form of one entity per line; where an entity is the core unit representing a business object in the database. Project template prompt This is used to supplement attributes for each extracted entity. Each attribute includes a field name, data type, whether it is a primary key, and constraints. The attributes corresponding to the entity are output in tabular form. The constraints include not null and unique. Project template prompt This tool is used to analyze the possible relationships between entities, determine the type of relationship, and describe them in natural language. It outputs the entity relationships and relationship types in the form of a list. The relationship types include one-to-one, one-to-many, and many-to-many. Project template prompt It is used to integrate and generate a clear conceptual model structure description based on the extracted entities, attributes and relationships, including entities, attributes, relationships and relationship types, and output them in the form of a structured text table of conceptual model description; Project template prompt This is used to modify the entity, attribute, and relationship information in the given Python example code structure to generate Python code for drawing conceptual ER diagrams, so that Graphviz or other graphics libraries can be used to draw conceptual ER diagrams; Project template prompt This is used to create a mediation table for all many-to-many relationship types. If the relationship has attributes, they are also included in the mediation table. The new entity information is organized to transform special relationships into mediation entities, and a list of mediation entities and instructions on how to split them are output. Project template prompt This is used to relist all the disassembled connections, clearly label them, and represent all connections in a structured table format; Project template prompt Used to integrate entity and contact information after introducing intermediary entities, and output the logical model design content in the form of a logical model structured description table, including entity fields, contact and attribute descriptions; Project template prompt Using the reference logical model and the provided code template, output the Python code for the logical ER diagram to draw the logical ER diagram, reflecting the intermediary entities and the direction of relationships; Project template prompt This is used to generate a relational model that conforms to the first normal form based on the logical model information. Each table has one row, listing multiple information including table name, fields, primary and foreign keys, and is saved as a standard txt text file, where each row represents a relational table structure. Project template prompt This is used to extract functional dependencies from each relation and output the functional dependency relations in a standard txt text format, with one section for each relation. Project template prompt Used to generate constraints for each table based on attributes and relationship information and save them as a constraint list in TXT text format; Project template prompt This tool is used to generate foreign key constraints based on the needs of each entity, thereby generating integrity constraint check information and targets. The final output is a list of foreign key information in txt text format.
8. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; The memory is used to store computer programs; When the processor executes the program stored in the memory, it implements the steps of the method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-6.