The invention provides a method and a
system for establishing a relationship between data tables, and belongs to the technical field of
big data. Comprising the following steps: S1,
foreign key constraint: explaining how the
foreign key constraint maintains a relationship between tables, including
cascade operation and reference integrity, and discussing an implementation mode of the
foreign key constraint in a
database, such as use and optimization of an index; s2, a
connection table explains the effect of the
connection table in
processing a many-to-many relationship, including the structure and use of an intermediate table, and analyzes the influence of the
connection table on query performance and an optimization strategy; and S3, self-association: how self-association supports storage and query of
tree structure data is described, and advantages and disadvantages of self-association in
database design are discussed. According to the
system for establishing the data table relation, the foreign key constraint of the RDBMS is taken as a core, logical association is realized through the
primary key, the foreign key and the relation type definition, and the non-
relational database simulates the relation through a reference or embedded document, so that the
data consistency and the query efficiency are ensured.