Home > database >  Questions about the mysql database design, please give advice, details come in please, thank you!
Questions about the mysql database design, please give advice, details come in please, thank you!

Time:10-11

A table ([table has multiple companies])
B table (branch)
C table (business capital source type [table only two types of business: foreign investment business, local investment business])
D table (table/province, city) area need to build a tree
E table (business type table [five types of business])
F table (business project table)
Build relationships between each table is now:
Table A and table B: one-to-many, (each company set up branch office is different)
A table with F table: A one-to-many, (if the project is A branch of business, the table has A foreign key F B_ID corresponding to A branch, the corresponding C C_ID table A type of funding sources, D_ID D table corresponding area, E_ID corresponding E table A business type),
Above corresponding relations in line with the business model, but the following format is formed after to query, you also need to flip, according to the format is as follows:
Line: - the name of the company - (corresponding to A table)
Line: -- -- -- -- -- -- -- -- -- -- (D)
Line: -- -- -- -- -- sources (foreign-funded) - table (C)
Line: 1 -- - business type (E table business types)
Line: - according to project information table (F) how many project shows how much
Line: 2 -- - business type (E table business types)
Line: - according to project information table (F) how many project shows how much
So according to the types of corresponding business project...
Line: -- -- -- -- -- sources (local investment) - table (C)
Line: 1 -- - business type (E table business types)
Line: - according to project information table (F) how many project shows how much
Line: 2 -- - business type (E table business types)
Line: - according to project information table (F) how many project shows how much
So according to the types of corresponding business project...
Branch lines: -- -- -- -- -- -- -- -- -- -- -- -- -- -- (such as the business project is a branch, the corresponding table, B company above does not display, the display of the above company behind)
Line: -- -- -- -- -- -- -- -- -- -- (D)
Line: -- -- -- -- -- sources (foreign-funded) - table (C)
.
Excuse me, so that to build table relationships is reasonable, how to write SQL statements written several times can't complete the work, thank you?

CodePudding user response:

Add: query need according to the "region", "business type", "sources" and so on carries on the multidimensional query, display "business project" in different ways,

CodePudding user response:

Table design is not very reasonable, but you can use the

When the relationship between each table to create a View, query, fundamental conditions directly query the View, the View of the results correspond directly on your page to display the contents of the can
  • Related