CN110516010A - A kind of database entity relational model extracting method and device based on adjacency list - Google Patents

A kind of database entity relational model extracting method and device based on adjacency list Download PDF

Info

Publication number
CN110516010A
CN110516010A CN201910799710.8A CN201910799710A CN110516010A CN 110516010 A CN110516010 A CN 110516010A CN 201910799710 A CN201910799710 A CN 201910799710A CN 110516010 A CN110516010 A CN 110516010A
Authority
CN
China
Prior art keywords
vertex
turn
attribute
read
key
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910799710.8A
Other languages
Chinese (zh)
Other versions
CN110516010B (en
Inventor
王功明
雷昌然
王建华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Software Group Co Ltd
Original Assignee
Inspur Software Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Software Group Co Ltd filed Critical Inspur Software Group Co Ltd
Priority to CN201910799710.8A priority Critical patent/CN110516010B/en
Publication of CN110516010A publication Critical patent/CN110516010A/en
Application granted granted Critical
Publication of CN110516010B publication Critical patent/CN110516010B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/258Data format conversion from or to a database
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • G06F16/288Entity relationship models
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present invention provides a kind of database entity relational model extracting method and device based on adjacency list, belongs to database, entity relationship model, adjacency list technical field, the present invention is the following steps are included: S1: database table structure standardization;S2: the vertex table of adjacency list is constructed;S3: the side table of adjacency list is constructed;S4: the relationship type between table structure is calculated.Meanwhile the present invention also provides a kind of database entity relational model extraction elements based on adjacency list for realizing the above method.Theoretical basis of the invention is the incidence relation and relationship type derived between table structure according to table structure major key and external key, to obtain database entity relational model, and is stored using adjacency list.Entity relationship model can be directly acquired, supports the actual demands such as dynamic ontology creation, database structure conversion.

Description

A kind of database entity relational model extracting method and device based on adjacency list
Technical field
The present invention relates to database, entity relationship model, adjacency list technology more particularly to a kind of data based on adjacency list Library entity relationship model extracting method and device.
Background technique
Entity relationship model belong to database design in conceptual model, indicate information world Common Concepts and they Between connection, be that first layer from real world to information world is abstract, be the semantic description to data model, have relatively strong Semantic meaning representation ability.
Concept and relationship in entity relationship model is indicated using different types of data structure, is just obtained different types of Logical model, comprising: hierarchical model, network model, relational model, object oriented programming model.Wherein, widely used relational model It is basic data structure with bivariate table, indicates concept and relationship using major key and external key respectively.Logical model is imported into database Corresponding Database Systems can be generated in modeling software.Therefore, entity relationship model has important work in Database Modeling With.
In knowledge engineering field, need to extract the dynamic ontology for indicating knowledge from existing database, to establish spirit Changeable data model living, is convenient for data management and multi-source data integration.Dynamic ontology is by 3 part structure of object, attribute and relationship At and entity relationship model have similarity;So after extracting entity relationship model in database, by correcting on a small quantity With it is perfect, so that it may constitute required for dynamic ontology.Therefore, entity relationship model is the basis for constructing dynamic ontology.
Conventional relationship model is not necessarily the optimum data structure of big data in the database, uses hierarchical model or netted Model is more suitable for hierarchical relationship or complex relationship between presentation-entity, needs relationship model conversion to be hierarchical model or netted mould Type.With entity relationship model as intermediate medium, carrying out conversion is feasible scheme.Therefore, entity relationship model is database The basis of structure conversion.
But the information system of certain early stages can not find entity when Database Modeling originally due to overlong time Relational model is brought constant to the maintenance in later period;Certain Database Systems are safeguarded by different team, but fail to timely update Entity relationship model is also unfavorable for the upgrading in later period;In addition, when multiple database integrates, even if knowing each database Entity relationship model, be also difficult to obtain it is integrated after new database entity relationship model, be unfavorable for integrated planning.
In face of the above problem, need to automatically extract out corresponding entity relationship from database using reverse engineering approach Model.
Currently, certain database software (such as My SQL, Oracle) can extract ER figure, but it is not easy to obtain as mediant According to entity relationship model, can not support building dynamic ontology, database structure conversion etc. actual demands.
Summary of the invention
In order to solve the above technical problems, the invention proposes a kind of, the database entity relational model based on adjacency list is mentioned Method is taken, entity relationship model can be directly acquired, supports the actual demands such as dynamic ontology creation, database structure conversion.
The technical scheme is that
A kind of database entity relational model extracting method based on adjacency list, which comprises the following steps:
S1: database table structure standardization;
S2: the vertex table of adjacency list is constructed;
S3: the side table of adjacency list is constructed;
S4: the relationship type between table structure is calculated.
In the step S1, each table structure of database is expressed as being made of triple (attribute-name, major key, external key) Table, wherein " attribute-name " indicate Property Name, " major key " and " external key " respectively indicate the attribute whether be major key and outside Key, Y expression are that N indicates no.
In the step S2, specifically include:
S21: initialization vertex table is sky;
S22: the table structure TS after reading first standardization;
S23: building TS corresponding vertex VA, and be added in the table of vertex;In the step S23, specifically include:
S231: newly-built vertex VA;
S232: the table name of table structure TS is set to the table name of vertex VA;
S233: first attribute TA of table structure TS is read;
S234: " attribute-name " of TA is added in the attribute-name array of vertex VA;
S235: if " major key " value of TA is Y, turns S236, otherwise turn S237;
S236: " attribute-name " of TA is added in the major key of vertex VA;
S237: if " external key " value of TA is Y, turns S238, otherwise turn S239;
S238: " attribute-name " of TA is added in the external key of vertex VA;
S239: judge whether attribute reads and finish, if not provided, turning S23A, otherwise turn S23B;
S23A: next attribute TA is read, S234 is turned;
S23B: vertex VA is added in the table of vertex.
S24: judge whether table structure reads and finish, if not provided, turning S25, otherwise turn S26;
S25: next table structure TS is read, S23 is turned;
S26: vertex table generated is returned.
In the step S3, specifically include:
S31: initialization side table is sky;
S32: first vertex VA of vertex table is read;
S33: construction vertex VA corresponding side collection EdgeSet;In the step S33, specifically include:
S331: the attribute number Q of statistics vertex VA external key;
S332: initialization side collection EdgeSet is sky, and processed external key set ProcedKey is sky, the category of major key to be tested Property number K=Q;
S333: external key number t=0 has been tested in initialization, has tested external key set TestKeySet as sky;
S334: judging whether t is equal to C (Q, K), if be equal to, turns S33D, otherwise turns S335;
S335: K attribute is selected from the VA external key of vertex, constitutes major key set TestKey to be tested;
S336: if TestKey is not the subset of TestKeySet, turns S337, otherwise turn S335;
S337: external key number t=t+1 has been tested in update;
S338: if TestKey is not the subset of ProcedKey, turns S339, otherwise turn S334;
S339: traversal vertex table, the major key if there is certain vertex VB is TestKey, then turning S33A, is otherwise turned S334;
S33A: the pointer Pt_VB for being directed toward VB is generated;
S33B: Pt_VB is added to the pointer chained list end of EdgeSet;
S33C: ProcedKey=ProcedKey ∪ TestKey is updated, S334 is turned;
S33D: the attribute number K=K-1 of major key to be tested is updated;
S33E: if K is greater than 0, turns S333, otherwise turn S33F;
S33F: collection EdgeSet in side generated is returned.
S34: EdgeSet is added in the table of side;
S35: judge whether vertex table reads and finish, if not provided, turning S36, otherwise turn S37;
S36: next vertex VA is read, S33 is turned;
S37: side table generated is returned.
In the step S4, specifically include:
S41: first vertex VA of vertex table is read;
S42: the corresponding side collection EdgeSet of vertex VA is read;
S43: it calculates VA and EdgeSet and corresponds to the relationship type between table structure, generate new side collection EdgeSetRT;Institute It states in step S43, specifically includes:
S431: initialization EdgeSetRT is sky;
S432: the corresponding table structure TSA of VA is read;
S433: first element PT_VB in EdgeSet is read;
S434: the corresponding table structure TSB of PT_VB is read;
S435: the relationship type RT_VB between TSA and TSB is calculated;In the step S435, specifically include:
S4351: the major key PriKey_A and external key ForKey_A of TSA are read;
S4352: the major key PriKey_B and external key ForKey_B of TSB are read;
S4353: TSA major key and TSB external key membership PKA_in_FKB are calculated;It is specific to wrap in the step S4353 It includes:
S43531: if TSA major key is the subset of TSB external key, turns S43532, otherwise turn S43533;
S43532:PKA_in_FKB=1 turns S43534;
S43533:PKA_in_FKB=0;
S43534: PKA_in_FKB is returned.
S4354: TSB major key and TSA external key membership PKB_in_FKA are calculated;It is specific to wrap in the step S4354 It includes:
S43541: if TSB major key is the subset of TSA external key, turns S43542, otherwise turn S43543;
S43542:PKB_in_FKA=1 turns S43544;
S43543:PKB_in_FKA=0;
S43544: PKB_in_FKA is returned.
S4355: RT_VB is calculated according to PKA_in_FKB and PKB_in_FKA;In the step S4355, specifically include:
S43551: initialization RT_VB=-1;
S43552: if PKA_in_FKB==1 and PKB_in_FKA==1, turn S43553, otherwise turn S43554;
S43553:RT_VB=1 turns S4355A;
S43554: if PKA_in_FKB==1 and PKB_in_FKA==0, turn S43555, otherwise turn S43556
S43555:RT_VB=2 turns S4355A;
S43556: if PKA_in_FKB==0 and PKB_in_FKA==1, turn S43557, otherwise turn S43558;
S43557:RT_VB=3 turns S4355A;
S43558: if PKA_in_FKB==0 and PKB_in_FKA==0, turn S43559, otherwise turn S4355A;
S43559:RT_VB=4;
S4355A: relationship type RT_VB is returned.
S4356: relationship type RT_VB is returned.
S436: { PT_VB, RT_VB } is added to the pointer chained list end of EdgeSetRT;
S437: judge in EdgeSet whether element reads and finish, if not provided, turning S438, otherwise turn S439;
S438: next element PT_VB is read, S434 is turned;
S439: collection EdgeSetRT in side generated is returned.
S44: the while collection EdgeSet in table is deleted;
S45: will be when collection EdgeSetRT is added in table;
S46: judge whether vertex table reads and finish, if not provided, turning S47, otherwise turn S48;
S47: next vertex VA is read, S42 is turned;
S48: updated side table is returned.
The invention also discloses a kind of database entity relational model extraction element based on adjacency list, comprising:
Table structure standardized component M1, for being expressed as each table structure of database by triple (attribute-name, master Key, external key) constitute table;
Vertex table structural member M2, for constructing the vertex table of adjacency list;
Side table structural member M3, for constructing the side table of adjacency list;
Table structure relationship type calculating unit M4, for calculating the relationship type between table structure.
Wherein,
The vertex table structural member M2, specifically includes:
Vertex table initialisation unit M21, for initializing vertex table;
Table structure reads component M22, for reading standardization table structure;
Vertex structural member M23 for constructing the corresponding vertex of table structure, and is added in the table of vertex.
The side table structural member M3, specifically includes:
Side table initialisation unit M31, for initializing side table;
Component M32 is read on 1st class vertex, for reading the vertex for not yet constructing corresponding sides collection in adjacency list;
Side collection structural member M33, for constructing the side collection of vertex correspondence, and is added in the table of vertex.
The table structure relationship type calculating unit M4, specifically includes:
Component M41 is read on 2nd class vertex, for reading in adjacency list the not yet vertex of computational chart structural relation type;
Side collection reads component M42, for reading the side collection of vertex correspondence;
Relationship type calculating unit M43, for calculating the relationship type between vertex and corresponding sides collection table structure;
Side collection updates component M44, for generating new side collection according to calculated relationship type, deletes and replaces original side Collection.
The beneficial effects of the invention are as follows
Incidence relation and relationship type between table structure are derived according to table structure major key and external key, to obtain data Library entity relationship model, and stored using adjacency list, easy to operate and speed quickly, solves entity relationship model and is not easy The problem of acquisition, can directly acquire entity relationship model, support dynamic ontology creation, database structure conversion etc. are practical to need It asks.
Detailed description of the invention
Fig. 1 is the step flow chart of the database entity relational model extracting method of the invention based on adjacency list;
Fig. 2 is the specific steps flow chart of step S2;
Fig. 3 is the specific steps flow chart of step S23;
Fig. 4 is the vertex table obtained after 1~table of processing table 5;
Fig. 5 is the detailed construction of teachers' instruction table corresponding vertex;
Fig. 6 is the specific steps flow chart of step S3;
Fig. 7 is the specific steps flow chart of step S33;
Fig. 8 is the adjacency list being made of vertex table and Bian Biao;
Fig. 9 is the Students' Score List side collection for adding relationship type;
Figure 10 is the specific steps flow chart of step S4;
Figure 11 is the specific steps flow chart of step S43;
Figure 12 is the specific steps flow chart of step S435;
Figure 13 is the specific steps flow chart of step S4353;
Figure 14 is the specific steps flow chart of step S4354;
Figure 15 is the specific steps flow chart of step S4355;
Figure 16 is the adjacency list with relationship type;
Figure 17 is the structural block diagram of the database entity relational model extraction element of the invention based on adjacency list;
Figure 18 is the structural block diagram of vertex table structural member M2;
Figure 19 is the structural block diagram of side table structural member M3;
Figure 20 is the structural block diagram of table structure relationship type calculating unit M4.
Specific embodiment
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is A part of the embodiment of the present invention, instead of all the embodiments, based on the embodiments of the present invention, those of ordinary skill in the art Every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
The present invention is realized by the following scheme: a kind of database entity relational model extracting method based on adjacency list, such as Shown in Fig. 1, comprising the following steps:
S1: database table structure standardization;
Each table structure of database is expressed as the table being made of triple (attribute-name, major key, external key) by this step, Wherein, " attribute-name " indicates that Property Name, " major key " and " external key " respectively indicate whether the attribute is major key and external key, and Y is indicated It is that N indicates no.
If including 5 tables in certain database, structure is as follows:
A, Xue Shengbiao: including field are as follows: class where student number, student name, students' genders, student's date of birth, student, Wherein student number is major key;
B, curriculum schedule: including field are as follows: course number, course name, course class hour, wherein course number is major key;
C, Students' Score List: including field are as follows: student number, course number, achievement are learned wherein (student number, course number) is major key Number and course number be the external key from other tables respectively;
D, Jiao Shibiao: include field are as follows: teacher's number, teacher's name, teacher's gender, teacher's date of birth, teachers' titles, Department where teacher, wherein teacher's number is major key;
E, teachers' instruction table: including field are as follows: course number, teacher's number, place of giving lessons, hours of instruction, wherein (course Number, teacher's number) it is major key, course number and teacher's number are the external key from other tables respectively.
The structure of above-mentioned 5 tables is standardized, as a result as shown in 1~table of table 5.
The standardization of 1 student's table structure of table
Attribute-name Major key External key
Student number Y N
Student name N N
Students' genders N N
Student's date of birth N N
Class where student N N
2 curriculum schedule construction standard of table
Attribute-name Major key External key
Course number Y N
Course name N N
Course class hour N N
3 Students' Score List construction standard of table
Attribute-name Major key External key
Student number Y Y
Course number Y Y
Achievement N N
The standardization of 4 teacher's table structure of table
Attribute-name Major key External key
Teacher's number Y N
Teacher's name N N
Teacher's gender N N
Teacher's date of birth N N
Teachers' titles N N
Department where teacher N N
The standardization of 5 teachers' instruction table structure of table
Attribute-name Major key External key
Course number Y Y
Teacher's number Y Y
It gives lessons place N N
Hours of instruction N N
S2: the vertex table of adjacency list is constructed;
Vertex table is one-dimension array, records each table structure information, including table name, attribute-name array, major key and external key;Belong to Property name array element save the title of each attribute, major key and external key are arrays, save major key and the corresponding category of external key respectively Property name.
Further, as shown in Fig. 2, being specifically included in the step S2:
S21: initialization vertex table is sky;
S22: the table structure TS after reading first standardization;
S23: building TS corresponding vertex VA, and be added in the table of vertex;
Further, as shown in figure 3, being specifically included in the step S23:
S231: newly-built vertex VA;
S232: the table name of table structure TS is set to the table name of vertex VA;
S233: first attribute TA of table structure TS is read;
S234: " attribute-name " of TA is added in the attribute-name array of vertex VA;
S235: if " major key " value of TA is Y, turns S236, otherwise turn S237;
S236: " attribute-name " of TA is added in the major key of vertex VA;
S237: if " external key " value of TA is Y, turns S238, otherwise turn S239;
S238: " attribute-name " of TA is added in the external key of vertex VA;
S239: judge whether attribute reads and finish, if not provided, turning S23A, otherwise turn S23B;
S23A: next attribute TA is read, S234 is turned;
S23B: vertex VA is added in the table of vertex.
S24: judge whether table structure reads and finish, if not provided, turning S25, otherwise turn S26;
S25: next table structure TS is read, S23 is turned;
S26: vertex table generated is returned.
Aforesaid operations are carried out to 1~table of table 5, obtained vertex table is as shown in Figure 4.
In Fig. 4, along sequence from top to bottom, every row indicates the corresponding vertex of 1 table structure.Every row is divided into left and right two Part, left side are vertex informations, including table name, attribute-name array (being indicated with AL), major key (being indicated with PK) and external key (use FK table Show);Right side is the side collection of vertex correspondence, is initially empty.Since length is limited, we only list the detailed knot on the 3rd vertex Fig. 4 Structure, as shown in figure 5, the detailed construction on other vertex is similarly.
S3: the side table of adjacency list is constructed;
In the ER figure indicated with adjacency list, vertex record sheet structural information, if two table structures there are incidence relation, So connect a line between their corresponding vertexs;For each vertex in vertex set, using the storage of pointer chained list comprising being somebody's turn to do The storage position on another vertex in the side of vertex may be constructed the side collection on the vertex;The set of all vertex sides collection, it is referred to as adjacent Connect the side table of table.
Further, as shown in fig. 6, being specifically included in the step S3:
S31: initialization side table is sky;
S32: first vertex VA of vertex table is read;
S33: construction vertex VA corresponding side collection EdgeSet;
Further, as shown in fig. 7, being specifically included in the step S33:
S331: the attribute number Q of statistics vertex VA external key;
S332: initialization side collection EdgeSet is sky, and processed external key set ProcedKey is sky, the category of major key to be tested Property number K=Q;
S333: external key number t=0 has been tested in initialization, has tested external key set TestKeySet as sky;
S334: judging whether t is equal to C (Q, K), if be equal to, turns S33D, otherwise turns S335;
S335: K attribute is selected from the VA external key of vertex, constitutes major key set TestKey to be tested;
S336: if TestKey is not the subset of TestKeySet, turns S337, otherwise turn S335;
S337: external key number t=t+1 has been tested in update;
S338: if TestKey is not the subset of ProcedKey, turns S339, otherwise turn S334;
S339: traversal vertex table, the major key if there is certain vertex VB is TestKey, then turning S33A, is otherwise turned S334;
S33A: the pointer Pt_VB for being directed toward VB is generated;
S33B: Pt_VB is added to the pointer chained list end of EdgeSet;
S33C: ProcedKey=ProcedKey ∪ TestKey is updated, S334 is turned;
S33D: the attribute number K=K-1 of major key to be tested is updated;
S33E: if K is greater than 0, turns S333, otherwise turn S33F;
S33F: collection EdgeSet in side generated is returned.
S34: EdgeSet is added in the table of side;
S35: judge whether vertex table reads and finish, if not provided, turning S36, otherwise turn S37;
S36: next vertex VA is read, S33 is turned;
S37: side table generated is returned.
Aforesaid operations are carried out to vertex table shown in Fig. 4, available side table constitutes complete adjoining by vertex table and Bian Biao Table, as shown in Figure 8.
In fig. 8, pointer is directed toward corresponding side collection on the right side of vertex, and side collection is the chain being made of the vertex pointer that is connected Table is defined as follows vertex pointer to indicate convenient:
A, PT_VBS: it is directed toward the pointer on " student's table " vertex;
B, PT_VBC: it is directed toward the pointer on " curriculum schedule " vertex;
C, PT_VBSC: it is directed toward the pointer on " Students' Score List " vertex;
D, PT_VBT: it is directed toward the pointer on " teacher's table " vertex;
E, PT_VBTC: it is directed toward the pointer on " teachers' instruction table " vertex;
In fig. 8, the side collection of " curriculum schedule " vertex correspondence includes PT_VBSC and PT_VBTC, indicates and " curriculum schedule " exists Incidence relation is " Students' Score List " and " teachers' instruction table ".
S4: the relationship type between table structure is calculated.
In order to indicate relationship type, need to add new field in the collection element of adjacency list side, as shown in Figure 9.
It being compared with Fig. 8, increased field RT_VBS indicates the relationship type between Students' Score List and student's table in Fig. 9, RT_VBC indicates the relationship type between Students' Score List and curriculum schedule.For the ease of indicating, we define relationship type value Range is 1,2,3,4, respectively indicates 1:1,1:N, M:1, M:N.
Further, as shown in Figure 10, it is specifically included in the step S4:
S41: first vertex VA of vertex table is read;
S42: the corresponding side collection EdgeSet of vertex VA is read;
S43: it calculates VA and EdgeSet and corresponds to the relationship type between table structure, generate new side collection EdgeSetRT;
Further, as shown in figure 11, it is specifically included in the step S43:
S431: initialization EdgeSetRT is sky;
S432: the corresponding table structure TSA of VA is read;
S433: first element PT_VB in EdgeSet is read;
S434: the corresponding table structure TSB of PT_VB is read;
S435: the relationship type RT_VB between TSA and TSB is calculated;
Further, as shown in figure 12, it is specifically included in the step S435:
S4351: the major key PriKey_A and external key ForKey_A of TSA are read;
S4352: the major key PriKey_B and external key ForKey_B of TSB are read;
S4353: TSA major key and TSB external key membership PKA_in_FKB are calculated;
Further, as shown in figure 13, it is specifically included in the step S4353:
S43531: if TSA major key is the subset of TSB external key, turns S43532, otherwise turn S43533;
S43532:PKA_in_FKB=1 turns S43534;
S43533:PKA_in_FKB=0;
S43534: PKA_in_FKB is returned.
S4354: TSB major key and TSA external key membership PKB_in_FKA are calculated;
Further, as shown in figure 14, it is specifically included in the step S4354:
S43541: if TSB major key is the subset of TSA external key, turns S43542, otherwise turn S43543;
S43542:PKB_in_FKA=1 turns S43544;
S43543:PKB_in_FKA=0;
S43544: PKB_in_FKA is returned.
S4355: RT_VB is calculated according to PKA_in_FKB and PKB_in_FKA;
Further, as shown in figure 15, it is specifically included in the step S4355:
S43551: initialization RT_VB=-1;
S43552: if PKA_in_FKB==1 and PKB_in_FKA==1, turn S43553, otherwise turn S43554;
S43553:RT_VB=1 turns S4355A;
S43554: if PKA_in_FKB==1 and PKB_in_FKA==0, turn S43555, otherwise turn S43556
S43555:RT_VB=2 turns S4355A;
S43556: if PKA_in_FKB==0 and PKB_in_FKA==1, turn S43557, otherwise turn S43558;
S43557:RT_VB=3 turns S4355A;
S43558: if PKA_in_FKB==0 and PKB_in_FKA==0, turn S43559, otherwise turn S4355A;
S43559:RT_VB=4;
S4355A: relationship type RT_VB is returned.
S4356: relationship type RT_VB is returned.
S436: { PT_VB, RT_VB } is added to the pointer chained list end of EdgeSetRT;
S437: judge in EdgeSet whether element reads and finish, if not provided, turning S438, otherwise turn S439;
S438: next element PT_VB is read, S434 is turned;
S439: collection EdgeSetRT in side generated is returned.
S44: the while collection EdgeSet in table is deleted;
S45: will be when collection EdgeSetRT is added in table;
S46: judge whether vertex table reads and finish, if not provided, turning S47, otherwise turn S48;
S47: next vertex VA is read, S42 is turned;
S48: updated side table is returned.
To adjacency list shown in Fig. 8 carry out aforesaid operations, the available adjacency list with relationship type, as shown in figure 16.
In Figure 16, the relationship type value of " curriculum schedule " vertex correspondence side collection element PT_VBSC (or PT_VBTC) is 2, Indicate that the relationship type between " curriculum schedule " and " Students' Score List " (or " teachers' instruction table ") is 1:N.
The present invention also provides a kind of database entity relational model extraction element based on adjacency list, as shown in figure 17, Include:
Table structure standardized component M1, for being expressed as each table structure of database by triple (attribute-name, master Key, external key) constitute table;
Vertex table structural member M2, for constructing the vertex table of adjacency list, as shown in figure 18, the vertex table structural member M2 includes:
Vertex table initialisation unit M21, for initializing vertex table;
Table structure reads component M22, for reading standardization table structure;
Vertex structural member M23 for constructing the corresponding vertex of table structure, and is added in the table of vertex.
Side table structural member M3, for constructing the side table of adjacency list, as shown in figure 19, the side table structural member M3 packet It includes:
Side table initialisation unit M31, for initializing side table;
Component M32 is read on 1st class vertex, for reading the vertex for not yet constructing corresponding sides collection in adjacency list;
Side collection structural member M33, for constructing the side collection of vertex correspondence, and is added in the table of vertex.
Table structure relationship type calculating unit M4, it is as shown in figure 20, described for calculating the relationship type between table structure Table structure relationship type calculating unit M4 includes:
Component M41 is read on 2nd class vertex, for reading in adjacency list the not yet vertex of computational chart structural relation type;
Side collection reads component M42, for reading the side collection of vertex correspondence;
Relationship type calculating unit M43, for calculating the relationship type between vertex and corresponding sides collection table structure;Bian Jigeng New component M44 is deleted for generating new side collection according to calculated relationship type and is replaced original side collection.
The foregoing is merely presently preferred embodiments of the present invention, is only used to illustrate the technical scheme of the present invention, and is not intended to limit Determine protection scope of the present invention.Any modification, equivalent substitution, improvement and etc. done all within the spirits and principles of the present invention, It is included within the scope of protection of the present invention.

Claims (9)

1. a kind of database entity relational model extracting method based on adjacency list, which is characterized in that
The following steps are included:
S1: database table structure standardization;
S2: the vertex table of adjacency list is constructed;
S3: the side table of adjacency list is constructed;
S4: the relationship type between table structure is calculated.
2. the method according to claim 1, wherein
In step sl, each table structure of database is expressed as the table being made of triple i.e. attribute-name, major key, external key Lattice, wherein " attribute-name " indicates Property Name, and " major key " and " external key " respectively indicates whether the attribute is major key and external key, Y table Showing is, N indicates no.
3. the method according to claim 1, wherein the step S2 is specifically included:
S21: initialization vertex table is sky;
S22: the table structure TS after reading first standardization;
S23: building TS corresponding vertex VA, and be added in the table of vertex;
It specifically includes:
S231: newly-built vertex VA;
S232: the table name of table structure TS is set to the table name of vertex VA;
S233: first attribute TA of table structure TS is read;
S234: " attribute-name " of TA is added in the attribute-name array of vertex VA;
S235: if " major key " value of TA is Y, turns S236, otherwise turn S237;
S236: " attribute-name " of TA is added in the major key of vertex VA;
S237: if " external key " value of TA is Y, turns S238, otherwise turn S239;
S238: " attribute-name " of TA is added in the external key of vertex VA;
S239: judge whether attribute reads and finish, if not provided, turning S23A, otherwise turn S23B;
S23A: next attribute TA is read, S234 is turned;
S23B: vertex VA is added in the table of vertex;
S24: judge whether table structure reads and finish, if not provided, turning S25, otherwise turn S26;
S25: next table structure TS is read, S23 is turned;
S26: vertex table generated is returned.
4. method according to claim 1, it is characterised in that: the step S3 is specifically included:
S31: initialization side table is sky;
S32: first vertex VA of vertex table is read;
S33: construction vertex VA corresponding side collection EdgeSet;
S331: the attribute number Q of statistics vertex VA external key;
S332: initialization side collection EdgeSet is sky, and processed external key set ProcedKey is sky, the attribute of major key to be tested Number K=Q;
S333: external key number t=0 has been tested in initialization, has tested external key set TestKeySet as sky;
S334: judging whether t is equal to C (Q, K), if be equal to, turns S33D, otherwise turns S335;
S335: K attribute is selected from the VA external key of vertex, constitutes major key set TestKey to be tested;
S336: if TestKey is not the subset of TestKeySet, turns S337, otherwise turn S335;
S337: external key number t=t+1 has been tested in update;
S338: if TestKey is not the subset of ProcedKey, turns S339, otherwise turn S334;
S339: traversal vertex table, the major key if there is certain vertex VB is TestKey, then turning S33A, otherwise turns S334;
S33A: the pointer Pt_VB for being directed toward VB is generated;
S33B: Pt_VB is added to the pointer chained list end of EdgeSet;
S33C: ProcedKey=ProcedKey ∪ TestKey is updated, S334 is turned;
S33D: the attribute number K=K-1 of major key to be tested is updated;
S33E: if K is greater than 0, turns S333, otherwise turn S33F;
S33F: collection EdgeSet in side generated is returned.
S34: EdgeSet is added in the table of side;
S35: judge whether vertex table reads and finish, if not provided, turning S36, otherwise turn S37;
S36: next vertex VA is read, S33 is turned;
S37: side table generated is returned.
5. according to the method described in claim 1, it is characterized by: the step S4 is specifically included:
S41: first vertex VA of vertex table is read;
S42: the corresponding side collection EdgeSet of vertex VA is read;
S43: it calculates VA and EdgeSet and corresponds to the relationship type between table structure, generate new side collection EdgeSetRT;
S431: initialization EdgeSetRT is sky;
S432: the corresponding table structure TSA of VA is read;
S433: first element PT_VB in EdgeSet is read;
S434: the corresponding table structure TSB of PT_VB is read;
S435: the relationship type RT_VB between TSA and TSB is calculated;
S4351: the major key PriKey_A and external key ForKey_A of TSA are read;
S4352: the major key PriKey_B and external key ForKey_B of TSB are read;
S4353: TSA major key and TSB external key membership PKA_in_FKB are calculated;
S43531: if TSA major key is the subset of TSB external key, turns S43532, otherwise turn S43533;
S43532:PKA_in_FKB=1 turns S43534;
S43533:PKA_in_FKB=0;
S43534: PKA_in_FKB is returned.
S4354: TSB major key and TSA external key membership PKB_in_FKA are calculated;
S43541: if TSB major key is the subset of TSA external key, turns S43542, otherwise turn S43543;
S43542:PKB_in_FKA=1 turns S43544;
S43543:PKB_in_FKA=0;
S43544: PKB_in_FKA is returned.
S4355: RT_VB is calculated according to PKA_in_FKB and PKB_in_FKA;
S43551: initialization RT_VB=-1;
S43552: if PKA_in_FKB==1 and PKB_in_FKA==1, turn S43553, otherwise turn S43554;
S43553:RT_VB=1 turns S4355A;
S43554: if PKA_in_FKB==1 and PKB_in_FKA==0, turn S43555, otherwise turn S43556
S43555:RT_VB=2 turns S4355A;
S43556: if PKA_in_FKB==0 and PKB_in_FKA==1, turn S43557, otherwise turn S43558;
S43557:RT_VB=3 turns S4355A;
S43558: if PKA_in_FKB==0 and PKB_in_FKA==0, turn S43559, otherwise turn S4355A;
S43559:RT_VB=4;
S4355A: relationship type RT_VB is returned.
S4356: relationship type RT_VB is returned.
S436: { PT_VB, RT_VB } is added to the pointer chained list end of EdgeSetRT;
S437: judge in EdgeSet whether element reads and finish, if not provided, turning S438, otherwise turn S439;
S438: next element PT_VB is read, S434 is turned;
S439: collection EdgeSetRT in side generated is returned.
S44: the while collection EdgeSet in table is deleted;
S45: will be when collection EdgeSetRT is added in table;
S46: judge whether vertex table reads and finish, if not provided, turning S47, otherwise turn S48;
S47: next vertex VA is read, S42 is turned;
S48: updated side table is returned.
6. a kind of database entity relational model extraction element based on adjacency list characterized by comprising
Table structure standardized component M1, for being expressed as each table structure of database by triple i.e. attribute-name, major key, outer The table that key is constituted;
Vertex table structural member M2, for constructing the vertex table of adjacency list;
Side table structural member M3, for constructing the side table of adjacency list;
Table structure relationship type calculating unit M4, for calculating the relationship type between table structure.
7. device according to claim 6, it is characterised in that: the vertex table structural member M2 is specifically included:
Vertex table initialisation unit M21, for initializing vertex table;
Table structure reads component M22, for reading standardization table structure;
Vertex structural member M23 for constructing the corresponding vertex of table structure, and is added in the table of vertex.
8. device according to claim 6, it is characterised in that: the side table structural member M3 is specifically included:
Side table initialisation unit M31, for initializing side table;
Component M32 is read on 1st class vertex, for reading the vertex for not yet constructing corresponding sides collection in adjacency list;
Side collection structural member M33, for constructing the side collection of vertex correspondence, and is added in the table of vertex.
9. device according to claim 6, it is characterised in that: the table structure relationship type calculating unit M4, it is specific to wrap It includes:
Component M41 is read on 2nd class vertex, for reading in adjacency list the not yet vertex of computational chart structural relation type;
Side collection reads component M42, for reading the side collection of vertex correspondence;
Relationship type calculating unit M43, for calculating the relationship type between vertex and corresponding sides collection table structure;
Side collection updates component M44, for generating new side collection according to calculated relationship type, deletes and replaces original side collection.
CN201910799710.8A 2019-08-28 2019-08-28 Database entity relation model extraction method and device based on adjacency list Active CN110516010B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910799710.8A CN110516010B (en) 2019-08-28 2019-08-28 Database entity relation model extraction method and device based on adjacency list

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910799710.8A CN110516010B (en) 2019-08-28 2019-08-28 Database entity relation model extraction method and device based on adjacency list

Publications (2)

Publication Number Publication Date
CN110516010A true CN110516010A (en) 2019-11-29
CN110516010B CN110516010B (en) 2023-06-09

Family

ID=68628426

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910799710.8A Active CN110516010B (en) 2019-08-28 2019-08-28 Database entity relation model extraction method and device based on adjacency list

Country Status (1)

Country Link
CN (1) CN110516010B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111190971A (en) * 2019-12-31 2020-05-22 浪潮软件股份有限公司 ER graph drawing method and device based on adjacency list node state and priority
CN113722294A (en) * 2021-09-01 2021-11-30 达梦数据技术(江苏)有限公司 Data migration method and system from graph database to relational database

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160342709A1 (en) * 2015-05-21 2016-11-24 International Business Machines Corporation Storing graph data in a relational database
CN108037916A (en) * 2017-11-29 2018-05-15 福州市智捷信息科技有限公司 A kind of graphical service modeling method based on web

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160342709A1 (en) * 2015-05-21 2016-11-24 International Business Machines Corporation Storing graph data in a relational database
CN108037916A (en) * 2017-11-29 2018-05-15 福州市智捷信息科技有限公司 A kind of graphical service modeling method based on web

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
李湘林: "关系数据库设计的实用方法及应用", 《网络财富》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111190971A (en) * 2019-12-31 2020-05-22 浪潮软件股份有限公司 ER graph drawing method and device based on adjacency list node state and priority
CN111190971B (en) * 2019-12-31 2023-08-01 浪潮软件股份有限公司 ER diagram drawing method and device based on neighbor table node state and priority
CN113722294A (en) * 2021-09-01 2021-11-30 达梦数据技术(江苏)有限公司 Data migration method and system from graph database to relational database
CN113722294B (en) * 2021-09-01 2024-02-23 达梦数据技术(江苏)有限公司 Data migration method and system from graph database to relational database

Also Published As

Publication number Publication date
CN110516010B (en) 2023-06-09

Similar Documents

Publication Publication Date Title
Gaede et al. Visualizing social acceptance research: A bibliometric review of the social acceptance literature for energy technology and fuels
Vaisman et al. Data warehouse systems
CN103577590A (en) Data query method and system
Corrado et al. Data structuring for the ontological modelling of urban energy systems: The experience of the SEMANCO project
CN100498785C (en) Multidimensional data reading and writing method and apparatus in on-line analytical processing system
CN111104394A (en) Energy data warehouse system construction method and device
CN110516010A (en) A kind of database entity relational model extracting method and device based on adjacency list
CN104021210B (en) Geographic data reading and writing method of MongoDB cluster of geographic data stored in GeoJSON-format semi-structured mode
CN103853820A (en) Data processing method and data processing system
CN104008209B (en) Reading-writing method for MongoDB cluster geographic data stored with GeoJSON format structuring method
CN104572856A (en) Converged storage method of service source data
CN111159154A (en) Energy data warehouse system
CN108875087A (en) A method of description things space attribute is simultaneously searched based on the description
Glake et al. Data management in multi-agent simulation systems
Di Tria et al. Research data mart in an academic system
Del Curto et al. GIS or BIM? A comparison applied to the conservation management plan of a 20th century architectural heritage
CN115168498A (en) Energy data multi-dimensional index derivation and summarization method and system
Eder et al. Data warehouse maintenance, evolution and versioning
TWI522827B (en) Real-time storage and real-time reading of huge amounts of data for non-related databases
Neil et al. Design method for a Historical Data Warehouse, explicit valid time in multidimensional models
Yang et al. Research on the application of digital technology in Conghua Traditional Village architecture and landscape protection
Dahlan et al. Transformation of data warehouse using snowflake scheme method
CN116431736B (en) Method and system for constructing online data warehouse model
Musa et al. Conceptual design of GIS database for heritage building in melaka
Palanisamy et al. Virtual DataStack for Application Domains: Concepts, Challenges and Generation Techniques

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant